Skip to content
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

Introduce argparse for argument parsing #7

Merged
merged 2 commits into from
Sep 8, 2021

Conversation

cbandera
Copy link
Contributor

@cbandera cbandera commented Sep 6, 2021

This addresses #5. I am not 100% happy with the restructuring, but I tried to not change the user interface and keep it as is.
The fact that passing no argument acts as it's own subcommand makes it hard to handle the argument parsing in a uniform way.

  • Can we introduce a new command "listfiles"?
  • Are you ok with the wording? And adjustments?

The proposed implementation uses "subparsers" to handle the subcommand, as this allows to make the positional arguments optional (which wouldn't be allowed otherwise without making them flags starting with "--"). This has the benefit however, that e.g. mrefilename can be cleanly handled as an argument to a subcommand so that it is possible to read it's documentation when calling pumla update --help.
The "hacky" part, which is providing a default attribute func for each subcommand and executing it after parsing is actually taken from the official documentation. It just get's a little more verbose, because we need to handle the "no argument provided" usecase.

The final output of calling pumla --help now looks like this:

usage: pumla [-h]  ...

pumla v0.8.0 - by Dr. Markus Voss (private person)

optional arguments:
  -h, --help    show this help message and exit

Available commands:
                Call without command to list available `pumla` files.
    listelements
                list all `pumla` model elements and diagrams of the model repository and diagram repository
    update      (re-)generate `modelrepo_json.puml` with updated info from `pumla` model elements found in repository.

@DrMarkusVoss
Copy link
Owner

  • Yes, we can we introduce a new command "listfiles"! And it would be better with that.
  • I tested it and I can see no difference in functionality of the implemented commands and the arg parsing looks much nicer, so I am happy with that.
  • the optional usage of the "mrefilename" when calling update has never been properly tested and documented by me, I am not even sure if the implementation does really support it yet, I only prepared it in the arg parser; I think that would be a feature for later that might be useful to deal with big projects where you integrate several subprojects where more than one is using pumla for documentation.... but I am still not sure if different model-repo-filenames will be the solution or something else.
  • where does it get more "verbose"? I didn't see it.

…now "--help". shortage of the command names.
@DrMarkusVoss
Copy link
Owner

did a small update on the commands and the proposed separate command to list the files.

@DrMarkusVoss DrMarkusVoss merged commit db4d350 into DrMarkusVoss:main Sep 8, 2021
@DrMarkusVoss DrMarkusVoss linked an issue Sep 21, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a descriptive helptext for pumla cli tool
2 participants