@@ -44,8 +44,8 @@ inline std::vector<wsl::windows::wslc::Argument> GetArgumentsForSet(ArgumentSet
4444 {
4545 case ArgumentSet::Run:
4646 return {
47- Argument::Create (ArgType::ContainerId , true ), // Required positional argument
48- Argument::Create (ArgType::Command, false ), // Optional positional argument
47+ Argument::Create (ArgType::ImageId , true ), // Required positional argument
48+ Argument::Create (ArgType::Command, false ), // Optional positional argument
4949 Argument::Create (ArgType::ForwardArgs, false ),
5050 Argument::Create (ArgType::Help),
5151 Argument::Create (ArgType::Interactive),
@@ -76,42 +76,50 @@ inline std::vector<wsl::windows::wslc::Argument> GetArgumentsForSet(ArgumentSet
7676#define WSLC_PARSER_TEST_CASES \
7777/* Simple case with required arg and simple other args */ \
7878WSLC_PARSER_TEST_CASE (Run, true , LR"( wslc -h)" ) \
79- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc cont1 )" ) \
80- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --verbose cont1 )" ) \
79+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc image1 )" ) \
80+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --verbose image1 )" ) \
8181\
8282/* Value tests, flag and non-flag, multi-value */ \
83- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --publish=80:80 cont1 )" ) \
84- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --publish 80:80 cont1 )" ) \
85- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -p=80:80 cont1 )" ) \
86- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -p 80:80 cont1 )" ) \
87- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -p 80:80 -p 443:443 cont1 )" ) \
88- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -p=80:80 -p=443:443 cont1 )" ) \
89- WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc --verbose --verbose cont1 )" ) \
83+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --publish=80:80 image1 )" ) \
84+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --publish 80:80 image1 )" ) \
85+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -p=80:80 image1 )" ) \
86+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -p 80:80 image1 )" ) \
87+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -p 80:80 -p 443:443 image1 )" ) \
88+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -p=80:80 -p=443:443 image1 )" ) \
89+ WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc --verbose --verbose image1 )" ) \
9090\
9191/* Flag parse tests */ \
92- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -h cont1 )" ) \
93- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -hi cont1 )" ) \
94- WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -ihp- cont1 )" ) \
95- WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -pih cont1 )" ) \
96- WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -pih=80:80 cont1 )" ) \
97- WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -pih 80:80 cont1 )" ) \
98- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -ihp 80:80 cont1 )" ) \
99- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -ihp=80:80 cont1 )" ) \
92+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -h image1 )" ) \
93+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -hi image1 )" ) \
94+ WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -ihp- image1 )" ) \
95+ WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -pih image1 )" ) \
96+ WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -pih=80:80 image1 )" ) \
97+ WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -pih 80:80 image1 )" ) \
98+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -ihp 80:80 image1 )" ) \
99+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -ihp=80:80 image1 )" ) \
100100\
101101/* Validation tests */ \
102- WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc --signal FOO cont1 )" ) \
103- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --signal 9 cont1 )" ) \
104- WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -t blah)" ) \
105- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -t 5)" ) \
102+ WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc --signal FOO image1 )" ) \
103+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --signal 9 image1 )" ) \
104+ WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc -t blah image1 )" ) \
105+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc -t 5 image1 )" ) \
106106\
107107/* Multi-positional tests */ \
108- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc cont1 command)" ) \
109- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc cont1 command --f -z forward hello world)" ) \
110- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc cont1 command forward hello world)" ) \
111- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc cont1 command forward"hello world")" ) \
112- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc cont1 command f="hello world" forward echo)" ) \
113- WSLC_PARSER_TEST_CASE(Run, false , LR"( wslc cont1 -v command f="hello world" forward echo)" ) \
114- WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc cont1 \\command\\?"" --f -z forward hello world)" ) \
108+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc image1 command)" ) \
109+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc image1 command --f -z forward hello world)" ) \
110+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc image1 command forward hello world)" ) \
111+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc image1 command forward"hello world")" ) \
112+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc image1 command f="hello world" forward echo)" ) \
113+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc --verbose image1 command f="hello world" forward echo)" ) \
114+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc image1 \\command\\?"" --f -z forward hello world)" ) \
115+ \
116+ /* Once the image name is parsed, the next token becomes the optional <command> positional \
117+ * and everything after that goes into ForwardArgs. Neither <command> nor ForwardArgs are \
118+ * interpreted as wslc options. The second case uses '\' + newline between tokens, which \
119+ * CommandLineToArgvW passes through as literal '\' tokens that the container shell \
120+ * handles correctly. */ \
121+ WSLC_PARSER_TEST_CASE(Run, true , LR"( wslc jrottenberg/ffmpeg:4.4-alpine ffmpeg -i http://url/to/media.mp4 -stats)" ) \
122+ WSLC_PARSER_TEST_CASE(Run, true , L" wslc jrottenberg/ffmpeg:4.4-alpine \\\n ffmpeg \\\n -i http://url/to/media.mp4 \\\n -stats" ) \
115123\
116124/* List cases with multiple args and flags that can come after the optional multi-positional. */ \
117125WSLC_PARSER_TEST_CASE(List, true , LR"( wslc)" ) \
0 commit comments