Class: Gzr::Commands::Role::Cat
- Inherits:
-
Gzr::Command
- Object
- Gzr::Command
- Gzr::Commands::Role::Cat
- Includes:
- FileHelper, Role
- Defined in:
- lib/gzr/commands/role/cat.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(role_id, options) ⇒ Cat
constructor
A new instance of Cat.
Methods included from FileHelper
Methods included from Role
#delete_role, #query_all_roles, #query_role, #query_role_groups, #query_role_users, #set_role_groups, #set_role_users
Methods inherited from Gzr::Command
#create_merge_query, #create_query, #field_expression, #field_names, #keys_to_keep, #merge_query, #pairs, #query, #render_csv, #run_inline_query
Methods included from Session
#build_connection_hash, #login, #logout_all, #pastel, #say_error, #say_ok, #say_warning, #v3_1_available?, #with_session
Constructor Details
#initialize(role_id, options) ⇒ Cat
Returns a new instance of Cat.
34 35 36 37 38 |
# File 'lib/gzr/commands/role/cat.rb', line 34 def initialize(role_id,) super() @role_id = role_id @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/gzr/commands/role/cat.rb', line 40 def execute(input: $stdin, output: $stdout) say_warning("options: #{@options.inspect}") if @options[:debug] with_session do data = query_role(@role_id) write_file(@options[:dir] ? "Role_#{data.id}_#{data.name}.json" : nil, @options[:dir], nil, output) do |f| f.puts JSON.pretty_generate(data.to_attrs) end end end |