MCPcopy Create free account
hub / github.com/catboost/catboost / TShellCommand

Class TShellCommand

util/system/shellcommand.h:352–496  ·  view source on GitHub ↗

* @brief Execute command in shell and provide its results * @attention Not thread-safe */

Source from the content-addressed store, hash-verified

350 * @attention Not thread-safe
351 */
352class TShellCommand: public TMoveOnly {
353private:
354 TShellCommand();
355
356public:
357 enum ECommandStatus {
358 SHELL_NONE,
359 SHELL_RUNNING,
360 SHELL_FINISHED,
361 SHELL_INTERNAL_ERROR,
362 SHELL_ERROR
363 };
364
365public:
366 /**
367 * @brief create the command with initial arguments list
368 *
369 * @param cmd binary name
370 * @param args arguments list
371 * @param options execution options
372 * @todo store entire options structure
373 */
374 TShellCommand(const TStringBuf cmd, const TList<TString>& args, const TShellCommandOptions& options = TShellCommandOptions(),
375 const TString& workdir = TString());
376 TShellCommand(const TStringBuf cmd, const TShellCommandOptions& options = TShellCommandOptions(), const TString& workdir = TString());
377 ~TShellCommand();
378
379public:
380 /**
381 * @brief append argument to the args list
382 *
383 * @param argument string argument
384 *
385 * @return self
386 */
387 TShellCommand& operator<<(const TStringBuf argument);
388
389 /**
390 * @brief return the collected output from the command.
391 * If the output stream is set, empty string will be returned
392 *
393 * @return collected output
394 */
395 const TString& GetOutput() const;
396
397 /**
398 * @brief return the collected error output from the command.
399 * If the error stream is set, empty string will be returned
400 *
401 * @return collected error output
402 */
403 const TString& GetError() const;
404
405 /**
406 * @brief return the internal error occured while watching
407 * the command execution. Should be called if execution
408 * status is SHELL_INTERNAL_ERROR
409 *

Callers 1

Y_UNIT_TESTFunction · 0.85

Calls 1

Tested by

no test coverage detected