Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Instead of --import paying attention to --format, leave --format
just for the export-format and give --import itself an optional
arguent that is the import format.  This of course defaults to 'jrnl'.
This allows argparse to do the choice-checking.
  • Loading branch information
pjz committed Aug 23, 2022
1 parent 72d1a04 commit ff3dc08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
11 changes: 6 additions & 5 deletions jrnl/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,19 @@ def parse_args(args=[]):
)
standalone.add_argument(
"--import",
action="store_const",
metavar="TYPE",
const=postconfig_import,
dest="postconfig_cmd",
dest="import_format",
nargs="?",
choices=IMPORT_FORMATS,
default="jrnl",
help=f"""
Import entries from another journal.
TYPE is the format to import [{util.oxford_list(IMPORT_FORMATS)}] (default: jrnl)
Optional parameters:
--file FILENAME (default: uses stdin)
--format [{util.oxford_list(IMPORT_FORMATS)}] (default: jrnl)
""",
)
standalone.add_argument(
Expand Down
3 changes: 1 addition & 2 deletions jrnl/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ def postconfig_import(args, config, **kwargs):
# Requires opening the journal
journal = open_journal(args.journal_name, config)

format = args.export if args.export else "jrnl"
get_importer(format).import_(journal, args.filename)
get_importer(args.import_format).import_(journal, args.filename)


def postconfig_encrypt(args, config, original_config, **kwargs):
Expand Down

0 comments on commit ff3dc08

Please sign in to comment.