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

available sub-commands are not displayed for pki-server <sub-command> --help #4932

Closed
taherrin opened this issue Jan 21, 2025 · 0 comments · Fixed by #4948
Closed

available sub-commands are not displayed for pki-server <sub-command> --help #4932

taherrin opened this issue Jan 21, 2025 · 0 comments · Fixed by #4948
Assignees

Comments

@taherrin
Copy link

taherrin commented Jan 21, 2025

Summary:

When using --help on a pki-server sub-command, the output is not correct and inconsistent.

Build:

OS: fedora-41
Build: dogtag-pki-11.6.0-0.3.alpha3.20250121163346UTC.bb22542e.fc41.x86_64
COPR: @pki/master

Steps to reproduce:

  1. Install dogtag-pki-server package
  2. Run the pki-server --help and then pki-server --help

Expected Result:

# pki-server --help
Usage: pki-server [OPTIONS]

  -v, --verbose                Run in verbose mode.
      --debug                  Show debug messages.
      --help                   Show help message.

Commands:
 create                        Create PKI server             
 remove                        Remove PKI server             
 status                        Display PKI service status    
 start                         Start PKI service             
 stop                          Stop PKI service              
 restart                       Restart PKI service           
 run                           Run PKI server in foreground  
 http                          HTTP management commands      
 listener                      Listener management commands  
 password                      Password management commands  
 nss                           NSS management commands       
 jss                           JSS management commands       
 webapp                        Webapp management commands    
 sd                            Security domain management commands
 ca                            CA management commands        
 kra                           KRA management commands       
 ocsp                          OCSP management commands      
 tks                           TKS management commands       
 tps                           TPS management commands       
 acme                          ACME management commands      
 est                           Manage the EST subsystem      
 banner                        Banner management commands    
 db                            Database management commands  
 instance                      Instance management commands  
 subsystem                     Subsystem management commands 
 migrate                       Migrate system                
 nuxwdog                       Nuxwdog related commands      
 cert                          System certificate management commands
 selftest                      Selftest management commands  
 upgrade                       Upgrade PKI server    

As was previously possible and is still possible with the pki command, adding a sub-command to the --help should display the options for it:

#   pki-server create --help
Usage: pki-server create [OPTIONS] []

      --user              User.
      --group             Group.
      --conf              Config folder
      --logs              Logs folder
      --with-maven-deps         Install Maven dependencies.
      --force                   Force creation.
  -v, --verbose                 Run in verbose mode.
      --debug                   Run in debug mode.
      --help                    Show help message.

Actual Result:

For the above example with sub-command create, it is currently displayed as this:

# pki-server create --help
Usage: pki-server [OPTIONS]

  -v, --verbose                Run in verbose mode.
      --debug                  Show debug messages.
      --help                   Show help message.

Commands:
 create                        Create PKI server             
 remove                        Remove PKI server             
 status                        Display PKI service status    
 start                         Start PKI service             
 stop                          Stop PKI service              
 restart                       Restart PKI service           
 run                           Run PKI server in foreground  
 http                          HTTP management commands      
 listener                      Listener management commands  
 password                      Password management commands  
 nss                           NSS management commands       
 jss                           JSS management commands       
 webapp                        Webapp management commands    
 sd                            Security domain management commands
 ca                            CA management commands        
 kra                           KRA management commands       
 ocsp                          OCSP management commands      
 tks                           TKS management commands       
 tps                           TPS management commands       
 acme                          ACME management commands      
 est                           Manage the EST subsystem      
 banner                        Banner management commands    
 db                            Database management commands  
 instance                      Instance management commands  
 subsystem                     Subsystem management commands 
 migrate                       Migrate system                
 nuxwdog                       Nuxwdog related commands      
 cert                          System certificate management commands
 selftest                      Selftest management commands  
 upgrade                       Upgrade PKI server 

Some sub-commands (ca, create...etc) display differently (showing a large list of various sub-commands) like this:

# pki-server ca --help
usage: pki-server [-i INSTANCE] [-v] [--debug] [--help]
                  {create,remove,status,start,stop,restart,run,http-connector-add,http-connector-del,http-connector-find,http-connector-mod,http-connector-show,http-connector-host-add,http-connector-host-del,http-connector-host-find,http-connector-host-mod,http-connector-host-show,http-connector-cert-add,http-connector-cert-del,http-connector-cert-find,listener-find,password-find,password-add,password-del,nss-create,nss-remove,jss-enable,jss-disable,webapp-find,webapp-show,webapp-deploy,webapp-undeploy,sd-create,sd-subsystem-find,sd-subsystem-add,sd-subsystem-del,ca-create,ca-deploy,ca-undeploy,ca-redeploy,ca-audit-config-show,ca-audit-config-mod,ca-audit-event-find,ca-audit-event-show,ca-audit-event-enable,ca-audit-event-disable,ca-audit-event-update,ca-audit-file-find,ca-audit-file-verify,ca-cert-find,ca-cert-create,ca-cert-import,ca-cert-del,ca-cert-chain-export,ca-cert-request-find,ca-cert-request-show,ca-cert-request-import,ca-crl-show,ca-crl-ip-find,ca-crl-ip-show,ca-crl-ip-mod,ca-clone-prepare,ca-config-find,ca-config-show,ca-config-set,ca-config-unset,ca-db-config-show,ca-db-config-mod,ca-db-info,ca-db-create,ca-db-init,ca-db-empty,ca-db-remove,ca-db-upgrade,ca-db-access-grant,ca-db-access-revoke,ca-db-index-add,ca-db-index-rebuild,ca-db-repl-enable,ca-db-repl-agmt-add,ca-db-repl-agmt-init,ca-db-vlv-find,ca-db-vlv-add,ca-db-vlv-del,ca-db-vlv-reindex,ca-group-find,ca-group-member-find,ca-group-member-add,ca-group-member-del,ca-profile-find,ca-profile-import,ca-profile-mod,ca-range-show,ca-range-request,ca-range-update,ca-id-generator-show,ca-id-generator-update,ca-user-add,ca-user-find,ca-user-mod,ca-user-del,ca-user-show,ca-user-cert-find,ca-user-cert-add,ca-user-cert-del,ca-user-role-find,ca-user-role-add,ca-user-role-del,kra-create,kra-deploy,kra-undeploy,kra-redeploy,kra-audit-config-show,kra-audit-config-mod,kra-audit-event-find,kra-audit-event-show,kra-audit-event-enable,kra-audit-event-disable,kra-audit-event-update,kra-audit-file-find,kra-audit-file-verify,kra-clone-prepare,kra-config-find,kra-config-show,kra-config-set,kra-config-unset,kra-db-config-show,kra-db-config-mod,kra-db-info,kra-db-create,kra-db-init,kra-db-empty,kra-db-remove,kra-db-upgrade,kra-db-access-grant,kra-db-access-revoke,kra-db-index-add,kra-db-index-rebuild,kra-db-repl-enable,kra-db-repl-agmt-add,kra-db-repl-agmt-init,kra-db-vlv-find,kra-db-vlv-add,kra-db-vlv-del,kra-db-vlv-reindex,kra-group-find,kra-group-member-find,kra-group-member-add,kra-group-member-del,kra-range-show,kra-range-request,kra-range-update,kra-user-add,kra-user-find,kra-user-mod,kra-user-del,kra-user-show,kra-user-cert-find,kra-user-cert-add,kra-user-cert-del,kra-user-role-find,kra-user-role-add,kra-user-role-del,ocsp-create,ocsp-deploy,ocsp-undeploy,ocsp-redeploy,ocsp-audit-config-show,ocsp-audit-config-mod,ocsp-audit-event-find,ocsp-audit-event-show,ocsp-audit-event-enable,ocsp-audit-event-disable,ocsp-audit-event-update,ocsp-audit-file-find,ocsp-audit-file-verify,ocsp-clone-prepare,ocsp-crl-issuingpoint-find,ocsp-crl-issuingpoint-add,ocsp-config-find,ocsp-config-show,ocsp-config-set,ocsp-config-unset,ocsp-db-config-show,ocsp-db-config-mod,ocsp-db-info,ocsp-db-create,ocsp-db-init,ocsp-db-empty,ocsp-db-remove,ocsp-db-upgrade,ocsp-db-access-grant,ocsp-db-access-revoke,ocsp-db-index-add,ocsp-db-index-rebuild,ocsp-db-repl-enable,ocsp-db-repl-agmt-add,ocsp-db-repl-agmt-init,ocsp-db-vlv-find,ocsp-db-vlv-add,ocsp-db-vlv-del,ocsp-db-vlv-reindex,ocsp-group-find,ocsp-group-member-find,ocsp-group-member-add,ocsp-group-member-del,ocsp-user-add,ocsp-user-find,ocsp-user-mod,ocsp-user-del,ocsp-user-show,ocsp-user-cert-find,ocsp-user-cert-add,ocsp-user-cert-del,ocsp-user-role-find,ocsp-user-role-add,ocsp-user-role-del,tks-create,tks-deploy,tks-undeploy,tks-redeploy,tks-audit-config-show,tks-audit-config-mod,tks-audit-event-find,tks-audit-event-show,tks-audit-event-enable,tks-audit-event-disable,tks-audit-event-update,tks-audit-file-find,tks-audit-file-verify,tks-clone-prepare,tks-config-find,tks-config-show,tks-config-set,tks-config-unset,tks-db-config-show,tks-db-config-mod,tks-db-info,tks-db-create,tks-db-init,tks-db-empty,tks-db-remove,tks-db-upgrade,tks-db-access-grant,tks-db-access-revoke,tks-db-index-add,tks-db-index-rebuild,tks-db-repl-enable,tks-db-repl-agmt-add,tks-db-repl-agmt-init,tks-db-vlv-find,tks-db-vlv-add,tks-db-vlv-del,tks-db-vlv-reindex,tks-group-find,tks-group-member-find,tks-group-member-add,tks-group-member-del,tks-user-add,tks-user-find,tks-user-mod,tks-user-del,tks-user-show,tks-user-cert-find,tks-user-cert-add,tks-user-cert-del,tks-user-role-find,tks-user-role-add,tks-user-role-del,tps-create,tps-deploy,tps-undeploy,tps-redeploy,tps-audit-config-show,tps-audit-config-mod,tps-audit-event-find,tps-audit-event-show,tps-audit-event-enable,tps-audit-event-disable,tps-audit-event-update,tps-audit-file-find,tps-audit-file-verify,tps-clone-prepare,tps-config-find,tps-config-show,tps-config-set,tps-config-unset,tps-db-config-show,tps-db-config-mod,tps-db-info,tps-db-create,tps-db-init,tps-db-empty,tps-db-remove,tps-db-upgrade,tps-db-access-grant,tps-db-access-revoke,tps-db-index-add,tps-db-index-rebuild,tps-db-repl-enable,tps-db-repl-agmt-add,tps-db-repl-agmt-init,tps-db-vlv-find,tps-db-vlv-add,tps-db-vlv-del,tps-db-vlv-reindex,tps-group-find,tps-group-member-find,tps-group-member-add,tps-group-member-del,tps-user-add,tps-user-find,tps-user-mod,tps-user-del,tps-user-show,tps-user-cert-find,tps-user-cert-add,tps-user-cert-del,tps-user-role-find,tps-user-role-add,tps-user-role-del,acme-create,acme-remove,acme-deploy,acme-undeploy,acme-redeploy,acme-metadata-show,acme-metadata-mod,acme-database-show,acme-database-mod,acme-issuer-show,acme-issuer-mod,acme-realm-show,acme-realm-mod,est-create,est-remove,est-deploy,est-undeploy,banner-show,banner-validate,db-upgrade,db-schema-upgrade,instance-cert-export,instance-find,instance-show,instance-start,instance-stop,instance-migrate,instance-nuxwdog-enable,instance-nuxwdog-disable,instance-externalcert-add,instance-externalcert-del,subsystem-disable,subsystem-enable,subsystem-find,subsystem-show,subsystem-cert-find,subsystem-cert-show,subsystem-cert-export,subsystem-cert-update,subsystem-cert-validate,migrate,nuxwdog-enable,nuxwdog-disable,cert-find,cert-show,cert-validate,cert-update,cert-request,cert-create,cert-import,cert-export,cert-del,cert-fix,selftest-enable,selftest-disable,upgrade} ...
pki-server: error: argument command: invalid choice: 'ca' (choose from create, remove, status, start, stop, restart, run, http-connector-add, http-connector-del, http-connector-find, http-connector-mod, http-connector-show, http-connector-host-add, http-connector-host-del, http-connector-host-find, http-connector-host-mod, http-connector-host-show, http-connector-cert-add, http-connector-cert-del, http-connector-cert-find, listener-find, password-find, password-add, password-del, nss-create, nss-remove, jss-enable, jss-disable, webapp-find, webapp-show, webapp-deploy, webapp-undeploy, sd-create, sd-subsystem-find, sd-subsystem-add, sd-subsystem-del, ca-create, ca-deploy, ca-undeploy, ca-redeploy, ca-audit-config-show, ca-audit-config-mod, ca-audit-event-find, ca-audit-event-show, ca-audit-event-enable, ca-audit-event-disable, ca-audit-event-update, ca-audit-file-find, ca-audit-file-verify, ca-cert-find, ca-cert-create, ca-cert-import, ca-cert-del, ca-cert-chain-export, ca-cert-request-find, ca-cert-request-show, ca-cert-request-import, ca-crl-show, ca-crl-ip-find, ca-crl-ip-show, ca-crl-ip-mod, ca-clone-prepare, ca-config-find, ca-config-show, ca-config-set, ca-config-unset, ca-db-config-show, ca-db-config-mod, ca-db-info, ca-db-create, ca-db-init, ca-db-empty, ca-db-remove, ca-db-upgrade, ca-db-access-grant, ca-db-access-revoke, ca-db-index-add, ca-db-index-rebuild, ca-db-repl-enable, ca-db-repl-agmt-add, ca-db-repl-agmt-init, ca-db-vlv-find, ca-db-vlv-add, ca-db-vlv-del, ca-db-vlv-reindex, ca-group-find, ca-group-member-find, ca-group-member-add, ca-group-member-del, ca-profile-find, ca-profile-import, ca-profile-mod, ca-range-show, ca-range-request, ca-range-update, ca-id-generator-show, ca-id-generator-update, ca-user-add, ca-user-find, ca-user-mod, ca-user-del, ca-user-show, ca-user-cert-find, ca-user-cert-add, ca-user-cert-del, ca-user-role-find, ca-user-role-add, ca-user-role-del, kra-create, kra-deploy, kra-undeploy, kra-redeploy, kra-audit-config-show, kra-audit-config-mod, kra-audit-event-find, kra-audit-event-show, kra-audit-event-enable, kra-audit-event-disable, kra-audit-event-update, kra-audit-file-find, kra-audit-file-verify, kra-clone-prepare, kra-config-find, kra-config-show, kra-config-set, kra-config-unset, kra-db-config-show, kra-db-config-mod, kra-db-info, kra-db-create, kra-db-init, kra-db-empty, kra-db-remove, kra-db-upgrade, kra-db-access-grant, kra-db-access-revoke, kra-db-index-add, kra-db-index-rebuild, kra-db-repl-enable, kra-db-repl-agmt-add, kra-db-repl-agmt-init, kra-db-vlv-find, kra-db-vlv-add, kra-db-vlv-del, kra-db-vlv-reindex, kra-group-find, kra-group-member-find, kra-group-member-add, kra-group-member-del, kra-range-show, kra-range-request, kra-range-update, kra-user-add, kra-user-find, kra-user-mod, kra-user-del, kra-user-show, kra-user-cert-find, kra-user-cert-add, kra-user-cert-del, kra-user-role-find, kra-user-role-add, kra-user-role-del, ocsp-create, ocsp-deploy, ocsp-undeploy, ocsp-redeploy, ocsp-audit-config-show, ocsp-audit-config-mod, ocsp-audit-event-find, ocsp-audit-event-show, ocsp-audit-event-enable, ocsp-audit-event-disable, ocsp-audit-event-update, ocsp-audit-file-find, ocsp-audit-file-verify, ocsp-clone-prepare, ocsp-crl-issuingpoint-find, ocsp-crl-issuingpoint-add, ocsp-config-find, ocsp-config-show, ocsp-config-set, ocsp-config-unset, ocsp-db-config-show, ocsp-db-config-mod, ocsp-db-info, ocsp-db-create, ocsp-db-init, ocsp-db-empty, ocsp-db-remove, ocsp-db-upgrade, ocsp-db-access-grant, ocsp-db-access-revoke, ocsp-db-index-add, ocsp-db-index-rebuild, ocsp-db-repl-enable, ocsp-db-repl-agmt-add, ocsp-db-repl-agmt-init, ocsp-db-vlv-find, ocsp-db-vlv-add, ocsp-db-vlv-del, ocsp-db-vlv-reindex, ocsp-group-find, ocsp-group-member-find, ocsp-group-member-add, ocsp-group-member-del, ocsp-user-add, ocsp-user-find, ocsp-user-mod, ocsp-user-del, ocsp-user-show, ocsp-user-cert-find, ocsp-user-cert-add, ocsp-user-cert-del, ocsp-user-role-find, ocsp-user-role-add, ocsp-user-role-del, tks-create, tks-deploy, tks-undeploy, tks-redeploy, tks-audit-config-show, tks-audit-config-mod, tks-audit-event-find, tks-audit-event-show, tks-audit-event-enable, tks-audit-event-disable, tks-audit-event-update, tks-audit-file-find, tks-audit-file-verify, tks-clone-prepare, tks-config-find, tks-config-show, tks-config-set, tks-config-unset, tks-db-config-show, tks-db-config-mod, tks-db-info, tks-db-create, tks-db-init, tks-db-empty, tks-db-remove, tks-db-upgrade, tks-db-access-grant, tks-db-access-revoke, tks-db-index-add, tks-db-index-rebuild, tks-db-repl-enable, tks-db-repl-agmt-add, tks-db-repl-agmt-init, tks-db-vlv-find, tks-db-vlv-add, tks-db-vlv-del, tks-db-vlv-reindex, tks-group-find, tks-group-member-find, tks-group-member-add, tks-group-member-del, tks-user-add, tks-user-find, tks-user-mod, tks-user-del, tks-user-show, tks-user-cert-find, tks-user-cert-add, tks-user-cert-del, tks-user-role-find, tks-user-role-add, tks-user-role-del, tps-create, tps-deploy, tps-undeploy, tps-redeploy, tps-audit-config-show, tps-audit-config-mod, tps-audit-event-find, tps-audit-event-show, tps-audit-event-enable, tps-audit-event-disable, tps-audit-event-update, tps-audit-file-find, tps-audit-file-verify, tps-clone-prepare, tps-config-find, tps-config-show, tps-config-set, tps-config-unset, tps-db-config-show, tps-db-config-mod, tps-db-info, tps-db-create, tps-db-init, tps-db-empty, tps-db-remove, tps-db-upgrade, tps-db-access-grant, tps-db-access-revoke, tps-db-index-add, tps-db-index-rebuild, tps-db-repl-enable, tps-db-repl-agmt-add, tps-db-repl-agmt-init, tps-db-vlv-find, tps-db-vlv-add, tps-db-vlv-del, tps-db-vlv-reindex, tps-group-find, tps-group-member-find, tps-group-member-add, tps-group-member-del, tps-user-add, tps-user-find, tps-user-mod, tps-user-del, tps-user-show, tps-user-cert-find, tps-user-cert-add, tps-user-cert-del, tps-user-role-find, tps-user-role-add, tps-user-role-del, acme-create, acme-remove, acme-deploy, acme-undeploy, acme-redeploy, acme-metadata-show, acme-metadata-mod, acme-database-show, acme-database-mod, acme-issuer-show, acme-issuer-mod, acme-realm-show, acme-realm-mod, est-create, est-remove, est-deploy, est-undeploy, banner-show, banner-validate, db-upgrade, db-schema-upgrade, instance-cert-export, instance-find, instance-show, instance-start, instance-stop, instance-migrate, instance-nuxwdog-enable, instance-nuxwdog-disable, instance-externalcert-add, instance-externalcert-del, subsystem-disable, subsystem-enable, subsystem-find, subsystem-show, subsystem-cert-find, subsystem-cert-show, subsystem-cert-export, subsystem-cert-update, subsystem-cert-validate, migrate, nuxwdog-enable, nuxwdog-disable, cert-find, cert-show, cert-validate, cert-update, cert-request, cert-create, cert-import, cert-export, cert-del, cert-fix, selftest-enable, selftest-disable, upgrade)
edewata added a commit to edewata/pki that referenced this issue Feb 3, 2025
Previously if a user called pki-server CLI with a wrong
subcommand the ArgumentParser would show an auto-generated
error message. The message looks significantly different
from the help message already defined in print_help(), is
not well-formatted, and is not easy to customize.

To address the problem the PKIServerCLI.create_parser() has
been modified to use remainder instead of subparsers and the
create_parser() in the subcommands has been modified to
create a regular ArgumentParser object.

The pki-server has also been modified to provide a --version
to show the version number of the tool.

A new CLIException class has been added to distinguish a
normal CLI error message (e.g. invalid module) from unexpected
exception.

Resolves: dogtagpki#4932
edewata added a commit to edewata/pki that referenced this issue Feb 3, 2025
Previously if a user called pki-server CLI with a wrong
sub-command the ArgumentParser would show an auto-generated
error message which looks significantly different from the
help message already defined in print_help().

To make it more consistent the PKIServerCLI.create_parser()
and execute() have been modified to use remainder instead of
subparsers, and the create_parser() in the sub-commands has
been modified to create a regular ArgumentParser instead of
a sub-parser.

The pki-server has also been modified to provide a --version
to show the version number of the tool.

A new CLIException has been added to distinguish a normal
CLI error (which will generate a simple error message such
as "Invalid module") from unexpected exception which will
generate a full stack trace.

Resolves: dogtagpki#4932
edewata added a commit to edewata/pki that referenced this issue Feb 3, 2025
Previously if a user called pki-server CLI with a wrong
sub-command the ArgumentParser would show an auto-generated
error message which looks significantly different from the
help message already defined in print_help().

To make it more consistent the PKIServerCLI.create_parser()
and execute() have been modified to use remainder instead of
subparsers, and the create_parser() in the sub-commands has
been modified to create a regular ArgumentParser instead of
a sub-parser.

The pki-server has also been modified to provide a --version
to show the version number of the tool.

A new CLIException has been added to distinguish a normal
CLI error (which will generate a simple error message such
as "Invalid module") from unexpected exception which will
generate a full stack trace.

Resolves: dogtagpki#4932
edewata added a commit to edewata/pki that referenced this issue Feb 3, 2025
Previously if a user called pki-server CLI with a wrong
sub-command the ArgumentParser would show an auto-generated
error message which looks significantly different from the
help message already defined in print_help().

To fix the issue the PKIServerCLI.create_parser() and
execute() have been modified to use remainder instead of
subparsers, and the create_parser() in the sub-commands has
been modified to create a regular ArgumentParser instead of
a subparser.

Similar changes were made to the CLI base class to fix the
help messages for sub-commands (e.g. pki-server ca).

The pki-server has also been modified to provide a --version
option to show the version number of the tool.

A new CLIException has been added to distinguish a normal
CLI error (which will generate a simple error message such
as "Invalid module") from an unexpected exception which will
generate a full stack trace.

Resolves: dogtagpki#4932
@edewata edewata closed this as completed in 5a47222 Feb 4, 2025
@edewata edewata self-assigned this Feb 4, 2025
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 a pull request may close this issue.

2 participants