Skip to content

Support for custom Exit Code from Iced application #1884

@mayankjoshii

Description

@mayankjoshii

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I have a UI application written in iced, which performs various operation. To launch the UI I'm using run() method: UpdateDriver::run(Settings::default()) and currently this returns the exit code of type iced::Result, but I want the application to return custom exit code of type u8 based on the operation performed. Ex: 1(success), 2(failure), 3(reboot) etc.

I need help on how to do that.

Current WorkFlow

fn launch_ui_mode() -> iced::Result {
        UpdateDriver::run(Settings::default())
 }

Main Function:

fn main() -> ExitCode {

    let retcode: u8;
    let exec_type = get_execution_mode();

    if exec_mode == UI{ 
        retcode = launch_ui_mode();  //This is iced::Result type, I need u8 type
    }
    else{
        retcode = launch_cli_mode();
    }

    return ExitCode::from(retcode);
}

My application runs in both CLI and UI mode, form CLI mode I'm directly returning the u8 type exit code, need to implement that for UI mode too.

What is the expected behavior?

Expectation :

fn launch_ui_mode() -> u8 {
        UpdateDriver::run(Settings::default())
 }

Version

master

Operative System

Windows

Do you have any log output?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions