Skip to content

Commit

Permalink
Add version (-v and --version) option
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Sustrik <[email protected]>
  • Loading branch information
sustrik committed Apr 5, 2015
1 parent 6a49fa9 commit 7e46144
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion ribosome.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,14 @@ function rnawrite(s) {
rnaln += m == null ? 0 : m.length;
}

if (process.argv.length < 3) {
if (process.argv.length < 3 || process.argv[2] == "-h" ||
process.argv[2] == "--help") {
usage();
}
if (process.argv[2] == "-v" || process.argv[2] == "--version") {
process.stderr.write("ribosome code generator, version 1.14\n");
process.exit(1);
}

var rnaopt;
var dnafile;
Expand Down
3 changes: 2 additions & 1 deletion ribosome.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ def rethrow(e, rnafile, linemap):
import re

# Set up the arguments parser.
parser = argparse.ArgumentParser()
parser = argparse.ArgumentParser(
version = "ribosome code generator, version 1.14")
parser.add_argument('dna', type=file)
parser.add_argument('--rna', action='store_true')

Expand Down
6 changes: 5 additions & 1 deletion ribosome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,13 @@ def rnawrite(s)
################################################################################

# Parse the command line arguments.
if(ARGV.size() < 1)
if(ARGV.size() < 1 || ARGV[0] == "-h" || ARGV[0] == "--help")
usage()
end
if ARGV[0] == "-v" || ARGV[0] == "--version"
puts "ribosome code generator, version 1.14"
exit(1)
end
if ARGV[0] == "--rna"
if(ARGV.size() < 2)
usage()
Expand Down

0 comments on commit 7e46144

Please sign in to comment.