Adds console script and fix command line parsing
- Adds console script so that we can run craton <command> from the shell. - Some simple cleanup. Change-Id: Ic50ee734d7e60190d6f7808c63f782c2c20589d3
This commit is contained in:
parent
e9e8ac4158
commit
67718cb443
@ -117,26 +117,24 @@ class CratonShell(object):
|
|||||||
)
|
)
|
||||||
self.parser = subcommand_parser
|
self.parser = subcommand_parser
|
||||||
|
|
||||||
if options.help or not argv:
|
if options.help or ('help' in argv) or not argv:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
args = subcommand_parser.parse_args(argv)
|
args = subcommand_parser.parse_args(argv)
|
||||||
|
|
||||||
session = craton.Session(
|
session = craton.Session(
|
||||||
username=args.os_username,
|
username=args.os_username,
|
||||||
token=args.os_password,
|
token=args.os_password,
|
||||||
project_id=args.craton_project_id,
|
project_id=args.craton_project_id,
|
||||||
)
|
)
|
||||||
self.cc = client.Client(session, args.craton_url)
|
self.cc = client.Client(session, args.craton_url)
|
||||||
|
|
||||||
args.func(self.cc, args)
|
args.func(self.cc, args)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main entry-point for cratonclient's CLI."""
|
"""Main entry-point for cratonclient's CLI."""
|
||||||
try:
|
try:
|
||||||
CratonShell().main(map(encodeutils.safe_decode, sys.argv[1:]))
|
CratonShell().main([encodeutils.safe_decode(a) for a in sys.argv[1:]])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("ERROR: %s" % encodeutils.safe_encode(six.text_type(e)),
|
print("ERROR: %s" % encodeutils.safe_encode(six.text_type(e)),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user