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

Question: how to hook in to subcommand Help... #354

Closed
JRAndreassen opened this issue Sep 22, 2020 · 2 comments
Closed

Question: how to hook in to subcommand Help... #354

JRAndreassen opened this issue Sep 22, 2020 · 2 comments

Comments

@JRAndreassen
Copy link

JRAndreassen commented Sep 22, 2020

Hi..

I'm trying to get help implemented for an option...

target/release/my_agent.exe help scan
my_agent 0.1.1


USAGE:
    my_agent scan <OPTIONS>

DESCRIPTION:
    Perform Data Scan

POSITIONAL ARGUMENTS:
    extra

FLAGS:
    -d, --devicetype DEVICE-TYPE 
    -U, --url URL             URL or ip of target
    -m, --method METHOD       Authentication Method
    -u, --username USERNAME   Authentication User Name (root|admin|apiuser)
    -p, --password PASSWORD   Authentication Password
    --token TOKEN             Authentication token
    -c, --clientid CLIENTID   Authentication ClientId
    --clientsecret CLIENTSECRET
    --tenantid TENANTID       Authentication Tenant ID (M$)
    -e, --emailuser EMAILUSER E-Mail user name
    -r, --realm REALM         Authentication Realm
    -A, --action ACTION       SubDevice Instance or Action verb (reset|on|off...)
    -P, --actionparam ACTION-PARAM
    -C, --credentialname my-CREDS
    -v, --verbose             Show verbose message
    -t, --timeout TIMEOUT-MS  Connect timeout in milliseconds (Default 20sec/21000ms (default: 21000)
    -T, --timing              Activate timing mode (default: false)
    -l, --log_message LOG-MESSAGE
    -L, --log_path LOG-PATH   Log file base path

the option : "DEVICE-TYPE"
has a dynamic list of options...
Is there a way to hook into the help system to generate a list ?

Also... Is there a way to hook in with the "Graceful" shutdown ?
Given that my app uses Tokio:

    fn run(&self) {
        let _ = abscissa_tokio::run(&APPLICATION, 
            async{
...
                let upload_interval = 
                    Duration::from_secs(self.upload_interval.unwrap_or(60));
                info!("Starting agent Loop");
                loop {
                    APPLICATION.read().get_handler_controller().read()
                        .handle_tasks_until(&mut todo_list, upload_interval).await;
                    self.dump_data(&mut todo_list);
                    // &&##&& Termination condition ???
                }
            }
        );
    }

The application ahs the Shutdown method...
It would be handy if the "Runnable had a "shutdown(&mut self, shutdown: Shutdown)"
Or did I miss something ?

Thanks again for sharing this project...
It's been a great time saver...
JR

@tony-iqlusion
Copy link
Member

tony-iqlusion commented Oct 7, 2020

Is there a way to hook into the help system to generate a list ?

Not really. For what it's worth, we're looking at replacing the library we use for command line option parsing: #298

It would be handy if the "Runnable had a "shutdown(&mut self, shutdown: Shutdown)"
Or did I miss something ?

There's been some work on graceful shutdown in the signal handler, however the way you'd ultimately exit is by having fn run complete, at which point your program exits.

@tony-iqlusion
Copy link
Member

Closed by #562 (clap v3 migration)

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

No branches or pull requests

2 participants