Class: Conjur::DSLCommand
- Defined in:
- lib/conjur/command/dsl_command.rb
Direct Known Subclasses
Class Method Summary collapse
Methods inherited from Command
acting_as_option, api, command, command_impl_for_list, command_options_for_list, display, display_members, method_missing, require_arg
Methods included from IdentifierManipulation
#conjur_account, #full_resource_id, #get_kind_and_id_from_args
Class Method Details
.file_or_stdin_arg(args) ⇒ Object
25 26 |
# File 'lib/conjur/command/dsl_command.rb', line 25 def file_or_stdin_arg(args) end |
.run_script(args, options, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/conjur/command/dsl_command.rb', line 28 def run_script(args, , &block) filename = nil script = if script = args.pop filename = script script = File.read(script) else STDIN.read end require 'conjur/dsl/runner' runner = Conjur::DSL::Runner.new(script, filename) if context = [:context] runner.context = begin JSON.parse(File.read(context)) rescue Errno::ENOENT {} end end if block_given? block.call(runner) do runner.execute end else runner.execute end if context File.write(context, JSON.pretty_generate(runner.context)) File.chmod(0600, context) end puts JSON.pretty_generate(runner.context) end |