Skip to content

参数命令行解析问题 #2

Description

@yuanziran

代码中没有设置位置参数,为什么他会报位置参数错误
Util::argparser parse("ximage");
parse.set_program_name("ximage2d")
.add_help_option()
.add_option("-i", "--input", "input file (*.bin).")
.add_option("-x", "--xdim", "input xdim.")
.add_option("-y", "--ydim", "input ydim.")
.add_option("-X", "--xbegin", "xbegin default 0.0 ", 0.0)
.add_option("-Y", "--ybegin", "ybegin default 0.0 " , 0.0)
.add_option("", "--xinterval", "xinterval default 1.0 ", 1.0)
.add_option("", "--yinterval", "yinterval default 1.0 ", 1.0)
.add_optionstd::string("-t", "--title", "chart title default ",
"")
.add_option("-W", "--width", "window width default value 400", 400)
.add_option("-H", "--height", "window height default value 400", 400)
.parse(argc, argv);

程序运行结果
.\ximage2d.exe -i .\demo1-1911 -x 1 -y 100
(parse error) position argument number missmatching, give 3, but need 0
uncaptured command line arguments:
.\demo1-1911
1
100

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions