add help when no argument is given
fix #668, add check for no arguments passed.
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
Can one of the admins verify this patch?
@surajssd updated.
Works for me :+1: Good work!
LGTM
dropbox/dev/atomicapp pr_681 ✔ 5h7m
▶ atomicapp
usage: atomicapp {run,fetch,stop,genanswers} ...
This will fetch and run an Atomic App, a containerized application conforming to the Nulecule Specification
positional arguments:
{run,fetch,stop,genanswers}
optional arguments:
-V, --version Show the version and exit.
-v, --verbose Verbose output mode.
-q, --quiet Quiet output mode.
--mode {fetch,run,stop,genanswers}
The mode Atomic App is run in. This option has the
effect of switching the 'verb' that was passed by the
user as the first positional argument. This is useful
in cases where a user is not using the Atomic App cli
directly, but through another interface such as the
Atomic CLI. EX: `atomic run <IMAGE> --mode=genanswers`
--dry-run Don't actually call provider. The commands that should
be run will be logged but not run.
--answers-format {ini,json,xml,yaml}
The format for the answers.conf.sample file. Default:
ini
--namespace NAMESPACE
The namespace to use in the target provider
--providertlsverify {True,False}
Value for providertlsverify answers option.
--providertlsverify=False to disable tls verification
--providerconfig PROVIDERCONFIG
Value for providerconfig answers option.
--providercafile PROVIDERCAFILE
Value for providercafile answers option.
--providerapi PROVIDERAPI
Value for providerapi answers option.
--logtype {cockpit,color,nocolor,none}
Override the default logging output. The options are:
nocolor: we will only log to stdout; color: log to
stdout with color; cockpit: used with cockpit
integration; none: atomicapp will disable any logging.
If nothing is set and logging to file then 'nocolor'
by default. If nothing is set and logging to tty then
'color' by default.
dropbox/dev/atomicapp pr_681 ✔
hi @abhi1004. this works for me too. do you mind doing a couple of things before we merge:
- squash your commits down into 1, you currently have 3
- rebase onto latest master
If you need help with either of those ask us in #nulecule and we can help.
@dustymabe how about showing help on following also?
(atomic) [vagrant@centos7-adb ~]$ atomicapp run
[INFO] - main.py - Action/Mode Selected is: run
Error. Too few arguments. Must provide app_spec.
Run with '--help' for more info
(atomic) [vagrant@centos7-adb ~]$ atomicapp fetch
[INFO] - main.py - Action/Mode Selected is: fetch
Error. Too few arguments. Must provide app_spec.
Run with '--help' for more info
(atomic) [vagrant@centos7-adb ~]$ atomicapp stop
usage: atomicapp stop [-h] [-V] [-v] [-q] [--mode {fetch,run,stop,genanswers}]
[--dry-run] [--answers-format {ini,json,xml,yaml}]
[--namespace NAMESPACE]
[--providertlsverify {True,False}]
[--providerconfig PROVIDERCONFIG]
[--providercafile PROVIDERCAFILE]
[--providerapi PROVIDERAPI]
[--logtype {cockpit,color,nocolor,none}]
[--provider {docker,kubernetes,openshift,marathon}]
app_spec
atomicapp stop: error: too few arguments
(atomic) [vagrant@centos7-adb ~]$ atomicapp genanswers
[INFO] - main.py - Action/Mode Selected is: genanswers
Error. Too few arguments. Must provide app_spec.
Run with '--help' for more info
@abhi1004 @surajssd , I paste diff here and tested these changes, please make sure that is correct?
--- a/atomicapp/cli/main.py
+++ b/atomicapp/cli/main.py
@@ -337,6 +337,7 @@ class CLI():
help="The provider to use. Overrides provider value in answerfile.")
stop_subparser.add_argument(
"app_spec",
+ nargs='?',
help=('''
Path to the directory where the Atomic App is fetched
that is to be stopped.'''))
@@ -395,6 +396,9 @@ class CLI():
# of the line.
# NOTE: Also allow "mode" to override 'action' if specified
args, _ = self.parser.parse_known_args(cmdline)
+
+ if not args.app_spec and not os.environ.get('IMAGE'):
+ args = self.parser.parse_args([args.action, '-h'])
cmdline.remove(args.action) # Remove 'action' from the cmdline
if args.mode:
args.action = args.mode # Allow mode to override 'action'
@@ -408,8 +412,8 @@ class CLI():
# a directory if they want to for "run". For that reason we won't
# default the RUN label for Atomic App to provide an app_spec argument.
# In this case pick up app_spec from $IMAGE env var (set by RUN label).
- if args.app_spec is None:
- if os.environ.get('IMAGE') is not None:
+ if not args.app_spec:
+ if os.environ.get('IMAGE'):
logger.debug("Setting app_spec based on $IMAGE env var")
args.app_spec = os.environ['IMAGE']
else: