Class: Brut::CLI::Commands::ExecutionContext
- Inherits:
-
Object
- Object
- Brut::CLI::Commands::ExecutionContext
- Defined in:
- lib/brut/cli/commands/execution_context.rb
Overview
The context in which a command's execution is run. This holds essentially all values that are input to the command, including parsed command line options, unparsed arguments, the UNIX environment, and the three s/O streams (stderr, stdout, stdin).
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#executor ⇒ Object
readonly
Returns the value of attribute executor.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdin ⇒ Object
readonly
Returns the value of attribute stdin.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(argv: :default, options: :default, env: :default, stdout: :default, stderr: :default, stdin: :default, executor: :default) ⇒ ExecutionContext
constructor
A new instance of ExecutionContext.
Constructor Details
#initialize(argv: :default, options: :default, env: :default, stdout: :default, stderr: :default, stdin: :default, executor: :default) ⇒ ExecutionContext
Returns a new instance of ExecutionContext.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/brut/cli/commands/execution_context.rb', line 6 def initialize( argv: :default, options: :default, env: :default, stdout: :default, stderr: :default, stdin: :default, executor: :default ) @argv = argv == :default ? [] : argv @options = == :default ? Brut::CLI::Options.new({}) : @env = env == :default ? {} : env @stdout = Brut::CLI::Output.from_io(stdout == :default ? $stdout : stdout) @stderr = Brut::CLI::Output.from_io(stderr == :default ? $stderr : stderr) @stdin = stdin == :default ? $stdin : stdin @executor = executor == :default ? Brut::CLI::Executor.new(out: self.stdout, err: self.stderr) : executor end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
24 25 26 |
# File 'lib/brut/cli/commands/execution_context.rb', line 24 def argv @argv end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
24 25 26 |
# File 'lib/brut/cli/commands/execution_context.rb', line 24 def env @env end |
#executor ⇒ Object (readonly)
Returns the value of attribute executor.
24 25 26 |
# File 'lib/brut/cli/commands/execution_context.rb', line 24 def executor @executor end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
24 25 26 |
# File 'lib/brut/cli/commands/execution_context.rb', line 24 def @options end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
24 25 26 |
# File 'lib/brut/cli/commands/execution_context.rb', line 24 def stderr @stderr end |
#stdin ⇒ Object (readonly)
Returns the value of attribute stdin.
24 25 26 |
# File 'lib/brut/cli/commands/execution_context.rb', line 24 def stdin @stdin end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
24 25 26 |
# File 'lib/brut/cli/commands/execution_context.rb', line 24 def stdout @stdout end |