-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Implement a basic Subcommand structure. #212
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
Conversation
Added show method to show config at cwd. Added export method to export config at cwd.
Added actions for subcommands.
Set cfg write default value to None. This means that if no argument is provided, the configwriter will ask for location.
Make `export`'s log a bit clearer.
( I should have done this before I opened the PR. Soz guys)
Fix the definition of min_argvs
For the benefit of those who want to review this, I'd like to give a rundown of how the subcommand system will work.
And that's how this subcommand structure works. |
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.
- Issue: This should not happen we need a error message here.
- Suggestion: Move the ones, like the CLI in Green to centre
- Issue: Change the colour of the link to something else other then blue.
- Suggestion: Read Configuration Files should not be shown while writing cfg files
- Issue: Export command doesn't work
- Issue: Write Only what is edited into manim.cfg instead of writing everything.
- Nitpick:Create the directory before writing the file. PS> He told me correct command later.
Changed colour of link to green.
Instead, the program now asks the user if they want to export to the same directory they are reading from.
Eh, it doesn't look very nice. I'll let you be the judge: I haven't committed that change.
Yeah, shame powershell has a blue background. I have changed the link to green in the latest commit.
This is a byproduct of the fact that the config files are read before anything else happens when the command
The command
I have not touched the configwriter function in this PR. It, by default , writes the entire contents of
I have added a warning and made sure the directory is created before writing the file, in the latest commit. |
Agree with @Aathish04, centered titles don't look great.
I think they should be shown.
This is an interesting suggestion, and I'm on the fence about it. If you feel strongly about it @naveen521kk please open a new issue and let's keep it separate from this PR. |
As suggested by @huguesdevimeux Co-authored-by: Hugues Devimeux <36239975+huguesdevimeux@users.noreply.github.com>
Change cwd and change back in test_cfg_subcmd itself.
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.
I left some comments.
It's perfectly ok if you don't answer to all of them, as a lot of them are non-blocking and pure nitpicks :D)
Thank you @huguesdevimeux ! Co-authored-by: Hugues Devimeux <36239975+huguesdevimeux@users.noreply.github.com>
Changed a misleading exit message. As suggested by @huguesdevimeux :)
…nto cfg-subcommand
Thank you @huguesdevimeux ! Co-authored-by: Hugues Devimeux <36239975+huguesdevimeux@users.noreply.github.com>
…nto cfg-subcommand
@leotrs @naveen521kk @huguesdevimeux @XorUnison I think I've addressed all your recommendations. Feel free to tell me if there's anything else! |
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.
SGTM !
On my first review, I asked how can we add tests for this. Were those tests added? If not, please open a separate issue to that effect. EDIT: tried to merge but there are conflicts. @Aathish04 please resolve conflicts and feel free to merge. |
no need to create an issue. Add the test required in #193 |
Yes, the tests mentioned were added. |
List of Changes
write
,show
andexport
commands with said subparser.Writes a custom config file based off of
default.cfg
and saves it to the user config location if the level passed isuser
or to the current working directory if the level passed iscwd
. If no level is passed, the config file writer will ask the user where to save the config.Prints the Final Configuration at the current working directory to the Terminal.
Exports the Final Configuration at the current working directory to --dir.
manim-cfg
command.Motivation
The introduction of the Config File writer opened up a lot of possibilities for config related utilities as discussed in #201 . These utilities would go well under the
manim
command, under thecfg
subcommand, as suggested by @leotrs, and that is what this PR addresses.Explanation for Changes
A subparser for commands related to modifying the config files manim uses and creates has been added, and to this, 3 more sub-subparsers, for the
write
,show
andexport
subcommands have been added.The
manim-cfg
command has been removed, as it only linked to a single function from a single file, and implementing subcommands for every variant ofmanim-cfg
andmanimcm-cfg
would get very tedious. This command has been wholly replaced by the subcommands to manim mentioned previously.Testing Status
Tested with no errors, and outputs as expected.
Further Comments
I'm not entirely satisfied with the way I've implemented this. Currently, the
__main__
function inmain.py
has to be modified to not ask for a default file if thecfg
subcommand is invoked, and I feel like my solution was a tad too hacky. If a better way exists, don't hesitate to review this PR to shreds.Acknowledgement