lib/conjur/command/script.rb in conjur-cli-4.6.1 vs lib/conjur/command/script.rb in conjur-cli-4.7.0

- old
+ new

@@ -17,13 +17,13 @@ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # require 'conjur/authn' -require 'conjur/command' +require 'conjur/command/dsl_command' -class Conjur::Command::Authn < Conjur::Command +class Conjur::Command::Script < Conjur::DSLCommand self.prefix = :script desc "Run a Conjur DSL script" arg_name "script" command :execute do |c| @@ -32,33 +32,9 @@ c.desc "Load context from this config file, and save it when finished. The file permissions will be 0600 by default." c.arg_name "context" c.flag [:c, :context] c.action do |global_options,options,args| - filename = nil - if script = args.pop - filename = script - script = File.read(script) - else - script = STDIN.read - end - require 'conjur/dsl/runner' - runner = Conjur::DSL::Runner.new(script, filename) - if options[:context] - runner.context = begin - JSON.parse(File.read(options[:context])) - rescue Errno::ENOENT - {} - end - end - - result = runner.execute - - if options[:context] - File.write(options[:context], JSON.pretty_generate(runner.context)) - File.chmod(0600, options[:context]) - end - - puts JSON.pretty_generate(result) + run_script args, options end end end \ No newline at end of file