# # # patch "automate.cc" # from [587ea09df1504fe04b48e762aae4dceea128c2cd] # to [bd756a4748ebd98f1facf82800d2d3556096322b] # # patch "automate_stdio_helpers.hh" # from [03f4e756e3292af111da1994d11e4b9c33d1a520] # to [0b0173220d1a492e531f96396423d076c00580dc] # # patch "cmd_automate.cc" # from [097de531583e23f833f35f5b8b3e5e97dde90c1b] # to [ca222967f517eaa22e4793d359beab1dfe7ac92b] # ============================================================ --- automate.cc 587ea09df1504fe04b48e762aae4dceea128c2cd +++ automate.cc bd756a4748ebd98f1facf82800d2d3556096322b @@ -2344,9 +2344,10 @@ automate_stdio_shared_setup(app_state & void automate_stdio_helpers:: automate_stdio_shared_setup(app_state & app, vector const & cmdline, - vector > const & params, + vector > const * const params, commands::command_id & id, - commands::automate const * & acmd) + commands::automate const * & acmd, + force_ticker_t ft) { using commands::command_id; using commands::command; @@ -2395,7 +2396,7 @@ automate_stdio_shared_setup(app_state & commands::command_id() /* doesn't matter */, cmd, my_id_for_hook, 2, args, - ¶ms); + params); // disable user prompts, f.e. for password decryption app.opts.non_interactive = true; @@ -2403,7 +2404,8 @@ automate_stdio_shared_setup(app_state & // set a fixed ticker type regardless what the user wants to // see, because anything else would screw the stdio-encoded output - app.opts.ticker = "stdio"; + if (ft == force_stdio_ticker) + app.opts.ticker = "stdio"; } std::pair automate_stdio_helpers:: @@ -2426,7 +2428,7 @@ automate_stdio_shared_body(app_state & a { if (init_fn) init_fn(); - automate_stdio_shared_setup(app, cmdline, params, id, acmd); + automate_stdio_shared_setup(app, cmdline, ¶ms, id, acmd); } catch (option::option_error & e) { ============================================================ --- automate_stdio_helpers.hh 03f4e756e3292af111da1994d11e4b9c33d1a520 +++ automate_stdio_helpers.hh 0b0173220d1a492e531f96396423d076c00580dc @@ -23,14 +23,16 @@ public: class automate_stdio_helpers { public: + enum force_ticker_t { force_stdio_ticker, no_force_stdio_ticker }; static void automate_stdio_shared_setup(app_state & app, std::vector const & cmdline, std::vector > - const & params, + const * const params, commands::command_id & id, /* reference-to-pointer here is intentional */ - commands::automate const * & acmd); + commands::automate const * & acmd, + force_ticker_t ft = force_stdio_ticker); static std::pair automate_stdio_shared_body(app_state & app, std::vector const & cmdline, ============================================================ --- cmd_automate.cc 097de531583e23f833f35f5b8b3e5e97dde90c1b +++ cmd_automate.cc ca222967f517eaa22e4793d359beab1dfe7ac92b @@ -305,7 +305,6 @@ LUAEXT(mtn_automate, ) LUAEXT(mtn_automate, ) { - args_vector args; std::stringstream output; bool result = true; std::stringstream & os = output; @@ -329,56 +328,23 @@ LUAEXT(mtn_automate, ) L(FL("Starting call to mtn_automate lua hook")); + vector args; for (int i=1; i<=n; i++) { - arg_type next_arg(luaL_checkstring(LS, i), origin::user); - L(FL("arg: %s")%next_arg()); + string next_arg(luaL_checkstring(LS, i)); + L(FL("arg: %s") % next_arg); args.push_back(next_arg); } commands::command_id id; - { - for (args_vector::const_iterator iter = args.begin(); - iter != args.end(); iter++) - id.push_back(*iter); + commands::automate const * cmd; - E(!id.empty(), origin::user, F("no command found")); + automate_stdio_helpers:: + automate_stdio_shared_setup(*app_p, args, 0, + id, cmd, + automate_stdio_helpers::no_force_stdio_ticker); - set< commands::command_id > matches = - CMD_REF(automate)->complete_command(id); - if (matches.empty()) - { - E(false, origin::user, F("no completions for this command")); - } - else if (matches.size() > 1) - { - E(false, origin::user, - F("multiple completions possible for this command")); - } - - id = *matches.begin(); - } - commands::command const * cmd = CMD_REF(automate)->find_command(id); - I(cmd != NULL); - - - commands::command_id my_id_for_hook = id; - my_id_for_hook.insert(my_id_for_hook.begin(), utf8("automate", origin::internal)); - // group name - my_id_for_hook.insert(my_id_for_hook.begin(), utf8("automation", origin::internal)); - - commands::reapply_options(*app_p, - app_p->reset_info.cmd, commands::command_id() /*doesn't matter*/, - cmd, my_id_for_hook, 2, - args); - - // disable user prompts, for example for password decryption - app_p->opts.non_interactive = true; - - - args_vector & parsed_args = app_p->opts.args; - commands::automate const * acmd = dynamic_cast< commands::automate const * >(cmd); I(acmd);