Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Unhelpfully-aimed error-messages on subcommands #187

Open
@twilight-flower

Description

@twilight-flower

Consider this example/test source code:

use argh::FromArgs;#[derive(FromArgs)]/// ExamplestructArgs{#[argh(subcommand)]subcommand:Subcommand,}#[derive(FromArgs)]#[argh(subcommand)]enumSubcommand{One(SubcommandOption1),}#[derive(FromArgs)]#[argh(subcommand, name ="one")]/// First subcommandstructSubcommandOption1{#[argh(positional)]/// small numberone:u8,}fnmain(){let _args:Args = argh::from_env();}

Runningcargo run -- one 257 (or building and then running./test.exe one 257) on this will predictably fail, because the number 257 doesn't fit inside a u8. But let's look at the error message that gets returned on that failure:

Error parsing positional argument 'one' with value '257': number too large to fit in target typeRun test.exe --help for more information.

But note the jump! That's not the help page for the subcommand that contains the positional argument 'one'; that's the root help page for the overall command. Users are being directed to the wrong place! They'll need to manually navigate their way to finding the subcommand's help menu from there. Users less familiar with how argh organizes its help menus might not even realize that thereis a subcommand help menu they should be accessing instead.

I suggest, as an alternative, that, when a subcommand returns an error of this sort, the error message's direction-to-the-help-menu should point directly at the subcommand which threw the error. So, for instance, in this case,Run test.exe one --help for more information..

(All example code here was compiled and run on Windows 10, using argh 0.1.12.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp