Skip to content

Commit

Permalink
tox-quickstart: adding --help and --version commands (fixes tox-dev#315)
Browse files Browse the repository at this point in the history
Note:
  [root] positional argument is now always initialized
  with a default '.' value referring to the current directory
  • Loading branch information
Vaskó László committed Jul 15, 2017
1 parent 49415cf commit 70fe227
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tox/_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

import argparse
import sys
from os import path
from codecs import open
Expand Down Expand Up @@ -256,14 +257,25 @@ def write_file(fpath, mode, content):
''')


def parse_args(argv):
parser = argparse.ArgumentParser(
description='Command-line script to quickly setup tox.ini for a Python project.'
)
parser.add_argument(
'root', type=str, nargs='?', default='.',
help='Custom root directory to write tox.ini to. Defaults to current directory.'
)
parser.add_argument('--version', action='version', version='%(prog)s ' + __version__)

args = argv[1:]
return parser.parse_args(args)


def main(argv=sys.argv):
d = {}
args = parse_args(argv)

if len(argv) > 3:
print('Usage: tox-quickstart [root]')
return 1
elif len(argv) == 2:
d['path'] = argv[1]
d = {}
d['path'] = args.root

try:
ask_user(d)
Expand Down

0 comments on commit 70fe227

Please sign in to comment.