Sha256: 119bbd656a97b30107590e65ac1af1d580cadaeb79d779bbc0cafea0a71e7f52
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module Pcli module Services module Commands module Users class List < Dry::CLI::Command include Depends.on( 'api', 'api_manager', 'output', 'screen' ) desc 'Get a list of all admin users.' def call(*) spinner = nil response = api_manager.ensure_authenticated do spinner = SimpleSpinnerBar.start('Retrieving users...', output) r = api.users if r.failure? spinner.failure else spinner.success end r end if response.success? spinner.success output.puts output.puts TTY::Table.new( header: [ Pl.bold('ID'), Pl.bold('Username'), Pl.bold('Name') ], rows: response.json.map { |u| [u['id'], u['username'], u['name']] } ).render(:ascii) else spinner.failure output.puts Output::ServerError.show(response, output, screen) end CommandOutput.continue end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pcli-0.1.1 | lib/pcli/services/commands/users/list.rb |
pcli-0.1.0 | lib/pcli/services/commands/users/list.rb |