Looking for Unix style 'getopt' command line parsing in a Windows batch file

前端 未结 2 1046
后悔当初
后悔当初 2020-12-19 12:27

Can anyone help me find something to parse command line args in a Windows batch file like one would do in a Unix shell script using getopt/getopts? It doesn\'t have to be a

2条回答
  •  感动是毒
    2020-12-19 12:52

    You can you something like this (-h has no args, hence no shift after that, -b and -s take additional args, so shift them).

    :GETOPTS
     if /I "%1" == "-h" goto Help
     if /I "%1" == "-b" set BASE=%2 & shift
     if /I "%1" == "-s" set SQL=%2 & shift
     shift
    if not "%1" == "" goto GETOPTS
    

提交回复
热议问题