Class: CLIClassTool::Common
- Inherits:
-
Object
- Object
- CLIClassTool::Common
- Defined in:
- lib/cli_class_tool/common.rb
Overview
Common utility class providing logging, configuration, and shell execution methods
Constant Summary collapse
- ACTION_LIST =
List of available actions for this class
[ :list_actions ]
- ACTION_HELP =
Help text for actions
{}
Instance Method Summary collapse
-
#list_actions(opts) ⇒ Integer
List available actions.
-
#run(cmd, check_err = true) ⇒ String
Run a shell command.
-
#runGit(cmd, opts = {}, check_err = true) ⇒ String
Run a git command.
-
#runGitInteractive(cmd, opts = {}, check_err = true) ⇒ Boolean
Run a git command interactively.
-
#runSystem(cmd, check_err = true) ⇒ Boolean
Run a shell command using system() (interactive).
Instance Method Details
#list_actions(opts) ⇒ Integer
List available actions
165 166 167 168 |
# File 'lib/cli_class_tool/common.rb', line 165 def list_actions(opts) puts parent_module.getActionAttr("ACTION_LIST").map(){|x| parent_module.actionToString(x)}.join("\n") return 0 end |
#run(cmd, check_err = true) ⇒ String
Run a shell command
113 114 115 116 117 118 |
# File 'lib/cli_class_tool/common.rb', line 113 def run(cmd, check_err = true) cmd_debug('', cmd) ret = `cd #{@path} && #{cmd}`.chomp() abort_if_err(check_err, $?, ret) return ret end |
#runGit(cmd, opts = {}, check_err = true) ⇒ String
Run a git command
140 141 142 143 144 145 |
# File 'lib/cli_class_tool/common.rb', line 140 def runGit(cmd, opts={}, check_err = true) cmd_debug('git', cmd) ret = `cd #{@path} && #{opts[:env]} git #{cmd}`.chomp() abort_if_err(check_err, $?, ret) return ret end |
#runGitInteractive(cmd, opts = {}, check_err = true) ⇒ Boolean
Run a git command interactively
154 155 156 157 158 159 |
# File 'lib/cli_class_tool/common.rb', line 154 def runGitInteractive(cmd, opts={}, check_err = true) cmd_debug('git interactive', cmd) ret = system("cd #{@path} && #{opts[:env]} git #{cmd}") abort_if_err(check_err, $?) return ret end |
#runSystem(cmd, check_err = true) ⇒ Boolean
Run a shell command using system() (interactive)
126 127 128 129 130 131 |
# File 'lib/cli_class_tool/common.rb', line 126 def runSystem(cmd, check_err = true) cmd_debug('interactive', cmd) ret = system("cd #{@path} && #{cmd}") abort_if_err(check_err, $?) return ret end |