mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-21 05:28:31 +02:00
fix argument parsing for test suite
This commit is contained in:
parent
b5c671c055
commit
2522582b5d
2 changed files with 14 additions and 6 deletions
|
@ -166,10 +166,12 @@ def run(context, command, cache_dir=None):
|
|||
cache_dir = os.path.join("features", "cache", cache_dir)
|
||||
command = command.format(cache_dir=cache_dir)
|
||||
|
||||
args = ushlex(command)[1:]
|
||||
args = ushlex(command)
|
||||
|
||||
try:
|
||||
cli.run(args or None)
|
||||
context.exit_status = 0
|
||||
with patch('sys.argv', args):
|
||||
cli.run(args[1:])
|
||||
context.exit_status = 0
|
||||
except SystemExit as e:
|
||||
context.exit_status = e.code
|
||||
|
||||
|
|
12
jrnl/cli.py
12
jrnl/cli.py
|
@ -194,11 +194,14 @@ def parse_args(args=None):
|
|||
help="Opens an interactive interface for deleting entries.",
|
||||
)
|
||||
|
||||
if not args:
|
||||
args = []
|
||||
|
||||
# Handle '-123' as a shortcut for '-n 123'
|
||||
num = re.compile(r"^-(\d+)$")
|
||||
if args is None:
|
||||
args = []
|
||||
return parser.parse_args([num.sub(r"-n \1", a) for a in args])
|
||||
args = [num.sub(r"-n \1", arg) for arg in args]
|
||||
|
||||
return parser.parse_args(args)
|
||||
|
||||
|
||||
def guess_mode(args, config):
|
||||
|
@ -300,6 +303,9 @@ def configure_logger(debug=False):
|
|||
|
||||
|
||||
def run(manual_args=None):
|
||||
if manual_args is None:
|
||||
manual_args = sys.argv[1:]
|
||||
|
||||
args = parse_args(manual_args)
|
||||
|
||||
configure_logger(args.debug)
|
||||
|
|
Loading…
Add table
Reference in a new issue