Skip to content

Commit

Permalink
add help argument for detailed help. See #73. Fix #145. See #148.
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Jul 13, 2017
1 parent de5af1b commit a8f388e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
46 changes: 39 additions & 7 deletions doc/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Here you can see the command-line usage instructions for the main looper command
>looper --help
version: 0.6.0-rc2
version: 0.6.0-dev
usage: looper [-h] [-V] {run,summarize,destroy,check,clean} ...
looper - Loop through samples and submit pipelines.
Expand All @@ -41,11 +41,12 @@ Here you can see the command-line usage instructions for the main looper command
-V, --version show program's version number and exit
For subcommand-specific options, type: 'looper <subcommand> -h'
https://github.com/epigen/looper
https://github.com/epigen/looper For debug options, type: 'looper -h
--details'
>looper run --help
version: 0.6.0-rc2
version: 0.6.0-dev
usage: looper run [-h] [-t TIME_DELAY] [--ignore-flags] [--compute COMPUTE]
[--env ENV] [--limit LIMIT] [--file-checks] [-d]
[--sp SUBPROJECT]
Expand Down Expand Up @@ -73,7 +74,7 @@ Here you can see the command-line usage instructions for the main looper command
>looper summarize --help
version: 0.6.0-rc2
version: 0.6.0-dev
usage: looper summarize [-h] [--file-checks] [-d] [--sp SUBPROJECT]
config_file
Expand All @@ -89,7 +90,7 @@ Here you can see the command-line usage instructions for the main looper command
>looper destroy --help
version: 0.6.0-rc2
version: 0.6.0-dev
usage: looper destroy [-h] [--file-checks] [-d] [--sp SUBPROJECT] config_file
positional arguments:
Expand All @@ -104,7 +105,7 @@ Here you can see the command-line usage instructions for the main looper command
>looper check --help
version: 0.6.0-rc2
version: 0.6.0-dev
usage: looper check [-h] [--file-checks] [-d] [--sp SUBPROJECT] config_file
positional arguments:
Expand All @@ -119,7 +120,7 @@ Here you can see the command-line usage instructions for the main looper command
>looper clean --help
version: 0.6.0-rc2
version: 0.6.0-dev
usage: looper clean [-h] [--file-checks] [-d] [--sp SUBPROJECT] config_file
positional arguments:
Expand All @@ -131,3 +132,34 @@ Here you can see the command-line usage instructions for the main looper command
-d, --dry-run Don't actually submit the project/subproject.
--sp SUBPROJECT Name of subproject to use, as designated in the project's
configuration file
>looper --details --help
version: 0.6.0-dev
usage: looper [-h] [-V] [--logfile LOGFILE] [--verbosity {0,1,2,3,4}]
[--logging-level LOGGING_LEVEL] [--dbg]
{run,summarize,destroy,check,clean} ...
looper - Loop through samples and submit pipelines.
positional arguments:
{run,summarize,destroy,check,clean}
run Main Looper function: Submit jobs for samples.
summarize Summarize statistics of project samples.
destroy Remove all files of the project.
check Checks flag status of current runs.
clean Runs clean scripts to remove intermediate files of
already processed jobs.
optional arguments:
-h, --help show this help message and exit
-V, --version show program's version number and exit
--logfile LOGFILE Optional output file for looper logs (default: None)
--verbosity {0,1,2,3,4}
Choose level of verbosity (default: None)
--logging-level LOGGING_LEVEL
Set logging level (default: None)
--dbg Turn on debug mode (default: False)
For subcommand-specific options, type: 'looper <subcommand> -h'
https://github.com/epigen/looper
2 changes: 1 addition & 1 deletion looper/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.6.0-rc2"
__version__ = "0.6.0-dev"
19 changes: 15 additions & 4 deletions looper/looper.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,19 @@ def parse_arguments():

description = "%(prog)s - Loop through samples and submit pipelines."
epilog = "For subcommand-specific options, type: '%(prog)s <subcommand> -h'"

epilog += "\nhttps://github.com/epigen/looper"

preparser = argparse.ArgumentParser(add_help=False)
preparser.add_argument("--details", action="store_true", default=False)
args, remaining_args = preparser.parse_known_args()
if args.details:
# Showing detailed help.
suppress_details = False
else:
suppress_details = argparse.SUPPRESS
epilog += "\n For debug options, type: '%(prog)s -h --details'"

parser = VersionInHelpParser(
description=description, epilog=epilog,
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
Expand All @@ -57,16 +68,16 @@ def parse_arguments():

# Logging control
parser.add_argument("--logfile",
help=argparse.SUPPRESS)
help=suppress_details or "Optional output file for looper logs")
parser.add_argument("--verbosity",
type=int,
choices=range(len(_LEVEL_BY_VERBOSITY)),
help=argparse.SUPPRESS)
help=suppress_details or "Choose level of verbosity")
parser.add_argument("--logging-level",
help=argparse.SUPPRESS)
help=suppress_details or "Set logging level")
parser.add_argument("--dbg",
action="store_true",
help=argparse.SUPPRESS)
help=suppress_details or "Turn on debug mode")

subparsers = parser.add_subparsers(dest="command")

Expand Down
2 changes: 1 addition & 1 deletion update-usage-docs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
looper --help > USAGE.temp 2>&1

for cmd in run summarize destroy check clean; do
for cmd in run summarize destroy check clean "--details"; do
echo $cmd
echo -e "\n\n>looper $cmd --help" >> USAGE.temp
looper $cmd --help >> USAGE.temp 2>&1
Expand Down

0 comments on commit a8f388e

Please sign in to comment.