1. Brodie Rao
  2. cram

Commits

Brodie Rao  committed bc4a737

Add -v/--version flag

  • Participants
  • Parent commits 4d2381f
  • Branches default

Comments (0)

Files changed (3)

File README.txt

View file
 
       [Oo]ptions:
         -h, --help         show this help message and exit
+        -V, --version      show version information and exit
         -q, --quiet        don't print diffs
         -v, --verbose      show filenames and test status
         -i, --interactive  interactively merge changed test output

File cram.py

View file
     from optparse import OptionParser
 
     p = OptionParser(usage='cram [OPTIONS] TESTS...')
+    p.add_option('-V', '--version', action='store_true',
+                 help='show version information and exit')
     p.add_option('-q', '--quiet', action='store_true',
                  help="don't print diffs")
     p.add_option('-v', '--verbose', action='store_true',
                  help="don't reset common environment variables")
     opts, paths = p.parse_args(args)
 
+    if opts.version:
+        sys.stdout.write("""Cram CLI testing framework (version 0.4)
+
+Copyright (C) 2010 Brodie Rao <brodie@bitheap.org> and others
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+""")
+        return
+
     conflicts = [('-y', opts.yes, '-n', opts.no),
                  ('-q', opts.quiet, '-v', opts.verbose),
                  ('-q', opts.quiet, '-i', opts.interactive)]

File tests/cram.t

View file
   
   [Oo]ptions: (re)
     -h, --help         show this help message and exit
+    -V, --version      show version information and exit
     -q, --quiet        don't print diffs
     -v, --verbose      show filenames and test status
     -i, --interactive  interactively merge changed test output
     -n, --no           answer no to all questions
     --keep-tmpdir      keep temporary directories
     -E                 don't reset common environment variables
+  $ cram -V
+  Cram CLI testing framework (version 0.4)
+  
+  Copyright (C) 2010 Brodie Rao <brodie@bitheap.org> and others
+  This is free software; see the source for copying conditions. There is NO
+  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
   $ cram
   [Uu]sage: cram \[OPTIONS\] TESTS\.\.\. (re)
   [2]