New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Partial refactor of cli.py (mainly help screen and arg parsing) #991
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wren
changed the title
Start refactor of cli and arg parsing
Partial refactor of cli.py (mainly help screen and arg parsing)
Jul 4, 2020
wren
force-pushed
the
arg-parsing-redo-866
branch
from
July 26, 2020 00:07
cbb99d4
to
9dbda55
Compare
Fixes jrnl-org#520 -and parameter seems to only work for the default journal
Also, cleaned up the way the arg parser handles standalone commands. Rather than checking individually for each command, you can now register the command in the proper place, and it will be run with all known arguments (and cofig if available).
It's now part of args, and it's parsed into a function after the config is available
If a date was given with an entry, and the star was also was added, the star wouldn't be recognized if it was at the start of the title. Example that didn't work, but now works with this fix: jrnl "saturday: *Title words." This is to be consistent in starring functionality with and without a date in the entry.
If a date was given with an entry, and the star was also was added, the star wouldn't be recognized if it was at the start of the title. Example that didn't work, but now works with this fix: jrnl "saturday: *Title words." This is to be consistent in starring functionality with and without a date in the entry.
wren
force-pushed
the
arg-parsing-redo-866
branch
from
August 1, 2020 22:08
199c5d9
to
05090d8
Compare
micahellison
approved these changes
Aug 1, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great tests, nice refactoring, and it's a delight to see these argument bugs squashed. This will be nice to build off of. Thanks for your work on this.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #344
Fixes #374
Fixes #520
Fixes #814
Fixes #866
Fixes #875
This is a partial refactor (another PR to come soon) cli.py, specifically focused on the
arg parsing code, and the
run
function. For any args that were changed, I also addedthe old flag as a hidden option, so existing aliases and scripts will still work behind
the scenes.
Most of the changes are transparent to users, but will make life easier for
contributors.
Changes that affect users:
immediately after the argument (e.g.
--encrypt filename.txt
), they now take thatoptional string from an option (e.g.
--encrypt --file filename.txt
). Please notethat these additional flags are completely optional, and not giving these options has
the same default behavior as before. The affected flags are:
--import
(--import TYPE
is now--import --format TYPE
)--encrypt
(--encrypt FILENAME
is now--encrypt --file FILENAME
)--decrypt
(--decrypt FILENAME
is now--decrypt --file FILENAME
)Changes that don't affect users, but do affect contributors:
--list
and--encrypt
) are now housed in an argparseoption, and are executed at the correct time. This makes it easier to add more
commands later (commands.py), and reduces the amount of overhead tracking all the
various command line options that a user can specify. You can now add a standalone
command by simply writing a function (commands.py), and registering the function
in the arg parser (arg_parser.py). That's it. Then
jrnl --newcommand
will work asexpected.
and writing. This PR starts that work (although it's not complete). After searching,
you have the option to do various things with the search results (e.g. put them into
editor, delete them, display them in alternate format, etc). That's already how jrnl
works for the users, but the code will now better follow that flow.
not for them to stay there (we already have an issue to clean that file up Pull functionality out of util.py #737). The
functions here will be split into smaller files when that issue is dealt with.
behave tests.
importing, but can be used elsewhere as needed.
Checklist
for the same issue.