99void ffPrintCommand (FFCommandOptions * options )
1010{
1111 FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate ();
12- const char * error = ffProcessAppendStdOut (& result , (char * const []){
12+ const char * error = ffProcessAppendStdOut (& result , options -> param .length ? (char * const []){
13+ options -> shell .chars ,
14+ options -> param .chars ,
15+ options -> text .chars ,
16+ NULL
17+ } : (char * const []){
1318 options -> shell .chars ,
14- #ifdef _WIN32
15- "/c" ,
16- #else
17- "-c" ,
18- #endif
1919 options -> text .chars ,
2020 NULL
2121 });
@@ -58,6 +58,12 @@ bool ffParseCommandCommandOptions(FFCommandOptions* options, const char* key, co
5858 return true;
5959 }
6060
61+ if (ffStrEqualsIgnCase (subKey , "param" ))
62+ {
63+ ffOptionParseString (key , value , & options -> param );
64+ return true;
65+ }
66+
6167 if (ffStrEqualsIgnCase (subKey , "text" ))
6268 {
6369 ffOptionParseString (key , value , & options -> text );
@@ -86,6 +92,12 @@ void ffParseCommandJsonObject(FFCommandOptions* options, yyjson_val* module)
8692 continue ;
8793 }
8894
95+ if (ffStrEqualsIgnCase (key , "param" ))
96+ {
97+ ffStrbufSetS (& options -> param , yyjson_get_str (val ));
98+ continue ;
99+ }
100+
89101 if (ffStrEqualsIgnCase (key , "text" ))
90102 {
91103 ffStrbufSetS (& options -> text , yyjson_get_str (val ));
@@ -106,20 +118,23 @@ void ffGenerateCommandJsonConfig(FFCommandOptions* options, yyjson_mut_doc* doc,
106118 if (!ffStrbufEqual (& defaultOptions .shell , & options -> shell ))
107119 yyjson_mut_obj_add_strbuf (doc , module , "shell" , & options -> shell );
108120
121+ if (!ffStrbufEqual (& defaultOptions .param , & options -> param ))
122+ yyjson_mut_obj_add_strbuf (doc , module , "param" , & options -> param );
123+
109124 if (!ffStrbufEqual (& defaultOptions .text , & options -> text ))
110125 yyjson_mut_obj_add_strbuf (doc , module , "text" , & options -> text );
111126}
112127
113128void ffGenerateCommandJsonResult (FF_MAYBE_UNUSED FFCommandOptions * options , yyjson_mut_doc * doc , yyjson_mut_val * module )
114129{
115130 FF_STRBUF_AUTO_DESTROY result = ffStrbufCreate ();
116- const char * error = ffProcessAppendStdOut (& result , (char * const []){
131+ const char * error = ffProcessAppendStdOut (& result , options -> param .length ? (char * const []){
132+ options -> shell .chars ,
133+ options -> param .chars ,
134+ options -> text .chars ,
135+ NULL
136+ } : (char * const []){
117137 options -> shell .chars ,
118- #ifdef _WIN32
119- "/c" ,
120- #else
121- "-c" ,
122- #endif
123138 options -> text .chars ,
124139 NULL
125140 });
@@ -168,13 +183,20 @@ void ffInitCommandOptions(FFCommandOptions* options)
168183 "/bin/sh"
169184 #endif
170185 );
171-
186+ ffStrbufInitStatic (& options -> param ,
187+ #ifdef _WIN32
188+ "/c"
189+ #else
190+ "-c"
191+ #endif
192+ );
172193 ffStrbufInit (& options -> text );
173194}
174195
175196void ffDestroyCommandOptions (FFCommandOptions * options )
176197{
177198 ffOptionDestroyModuleArg (& options -> moduleArgs );
178199 ffStrbufDestroy (& options -> shell );
200+ ffStrbufDestroy (& options -> param );
179201 ffStrbufDestroy (& options -> text );
180202}
0 commit comments