You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using cement only from last 3-4 days. so, I am new to this framework. And I must say, I really like the framework @derks . Thank you for your work on this framework.
Cement exactly solves the problem I was having with other frameworks.
System Information
Cement Version: 3.0.8
Python Version: 3.10.9
Operating System and Version: Platform Linux-6.1.14-1-lts-x86_64-with-glibc2.37.
OS : Arch Linux
Steps to Reproduce (Bugs Only)
Below example is provided to reproduce bug.
What Am I trying to achieve
I am trying to define single options / Arguments in single module (python files) using Controllers.
Because I want to keep their functionality in separate file and then stack them onto base class.
In the below example, Embedded class will be defined in separate python file, just like here we have added Items Controller code.
Example
The following is an [MCVE] (Minimal Complete
Verifiable Example) that reproduces the issue:
# INSERT EXAMPLE CODE HEREfromcementimportApp, Controller, eximportsysclassBase(Controller):
classMeta:
label='base'arguments= [
(['-c','--count'],
{'help': 'takes numeric value',
'type': int,
'default': 1}),
]
def_default(self):
# if _default is not modified, then it is prints help by default as no commands# are parsed. help is printed even if self.app.pargs.name is parsediflen(sys.argv) ==1:
self.app.args.print_help()
classEmbedded(Controller):
classMeta:
label='embedded_controller'stacked_on='base'stacked_type='embedded'arguments= [
(['-n','--name'],
{'help': 'takes name',
'action': 'store'}),
]
def_post_argument_parsing(self):
count=self.app.pargs.countname=self.app.pargs.nameifnameisnotNone:
foriinrange(count):
print(name)
classMyApp(App):
classMeta:
label='myapp'handlers= [
Base,
Embedded,
]
withMyApp() asapp:
app.run()
Output of above Example
options:
-h, --help show this help message and exit
-d, --debug full application debug mode
-q, --quiet suppress all console output
-c COUNT, --count COUNT
takes numeric value
-n NAME, --name NAME takes name
sub-commands: <------------- unnecessary sub-commands
{}
Desired Output
options:
-h, --help show this help message and exit
-d, --debug full application debug mode
-q, --quiet suppress all console output
-c COUNT, --count COUNT
takes numeric value
-n NAME, --name NAME takes name
The text was updated successfully, but these errors were encountered:
@tomclad is the intention to have completely separate cli's, that can also be used from a single unified cli? I assume similar to the way git used to be?
Example 1: myapp [sub-controller]
Example 2: myapp-sub-controller (as a separate app)
I have not seen this use case before, but i'll be happy to try it out and figure out what needs to happen in order to remove the empty sub-commands from Argparse.
Cement Issue Reporting and Feature Requests
Pre-Note:
System Information
Steps to Reproduce (Bugs Only)
What Am I trying to achieve
Example
The following is an [MCVE] (Minimal Complete
Verifiable Example) that reproduces the issue:
Output of above Example
Desired Output
The text was updated successfully, but these errors were encountered: