Class: AssLauncher::Support::Shell::Command Private
- Inherits:
-
Object
- Object
- AssLauncher::Support::Shell::Command
- Defined in:
- lib/ass_launcher/support/shell.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
What reason for it? Reason for it:
Fucking 1C binary often unexpected parse cmd arguments if run in shell like ‘1c.exe arguments`. For correction this invented two way run 1C binary: as command see Command or as script see Script. If run 1C as command we can control executing process wait exit or kill 1C binary process. If run 1C as script 1C more correctly parse arguments but we can’t kill subprosess running in cmd.exe
On default use silient execute 1C binary whit /DisableStartupDialogs, /DisableStartupMessages parameters and capture 1C output /OUT parameter. Read message from /OUT when 1C binary process exit and build instnce of RunAssResult.
Fucking 1C not work with stdout and stderr For out 1C use /OUT“file” parameter and write message into. Message encoding ‘cp1251’ for windows and ‘utf-8’ for Linux
Command running directly as: popen3(command.cmd, *command.args, options)
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ silent_mode: true, capture_assout: true, disable_auto_check_version: true}.freeze
Instance Attribute Summary collapse
- #args ⇒ Object readonly private
- #cmd ⇒ Object readonly private
- #options ⇒ Object readonly private
- #process_holder ⇒ Object readonly private
Instance Method Summary collapse
- #capture_assout? ⇒ Boolean private
- #exit_handling(exitstatus, out, err) ⇒ Object private
-
#initialize(cmd, args = [], options = {}) ⇒ Command
constructor
private
A new instance of Command.
-
#run(options = {}) ⇒ ProcessHolder
private
Run command.
-
#running? ⇒ true
private
If command was already running.
- #to_s ⇒ Object private
Constructor Details
#initialize(cmd, args = [], options = {}) ⇒ Command
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Command.
120 121 122 123 124 125 126 127 |
# File 'lib/ass_launcher/support/shell.rb', line 120 def initialize(cmd, args = [], = {}) @options = DEFAULT_OPTIONS.merge().freeze @cmd = cmd @args = args validate_args @args += (_silent_mode + _disable_auto_check_version) @ass_out_file = _ass_out_file end |
Instance Attribute Details
#args ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/ass_launcher/support/shell.rb', line 101 def args @args end |
#cmd ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/ass_launcher/support/shell.rb', line 101 def cmd @cmd end |
#options ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/ass_launcher/support/shell.rb', line 101 def @options end |
#process_holder ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
102 103 104 |
# File 'lib/ass_launcher/support/shell.rb', line 102 def process_holder @process_holder end |
Instance Method Details
#capture_assout? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
147 148 149 |
# File 'lib/ass_launcher/support/shell.rb', line 147 def capture_assout? [:capture_assout] end |
#exit_handling(exitstatus, out, err) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
203 204 205 206 |
# File 'lib/ass_launcher/support/shell.rb', line 203 def exit_handling(exitstatus, out, err) RunAssResult.new(exitstatus, encode_out(out), encode_out(err), ass_out_file.read) end |
#run(options = {}) ⇒ ProcessHolder
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run command
159 160 161 162 |
# File 'lib/ass_launcher/support/shell.rb', line 159 def run( = {}) return process_holder if running? ProcessHolder.run(self, ) end |
#running? ⇒ true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns if command was already running.
152 153 154 |
# File 'lib/ass_launcher/support/shell.rb', line 152 def running? !process_holder.nil? end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
199 200 201 |
# File 'lib/ass_launcher/support/shell.rb', line 199 def to_s "#{cmd} #{args.join(' ')}" end |