Sha256: cf2bbbef62f8b11b1016ef25828ac8b04da4c9b269250ad7a07654147afb4de4

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

# frozen_string_literal: true

module Pcli
  module Services
    class AllCommands
      include Depends.on(
        user_show: 'commands.user.show',
        user_change: 'commands.user.change',
        user_password: 'commands.user.password',
        user_totp: 'commands.user.totp',
        users_list: 'commands.users.list',
        users_create: 'commands.users.create',
        users_change: 'commands.users.change',
        users_remove: 'commands.users.remove',
        templates_list: 'commands.templates.list',
        templates_change: 'commands.templates.change',
        login: 'commands.login',
        logout: 'commands.logout',
      )

      def registry
        me = self

        Module.new do
          extend Dry::CLI::Registry

          register 'user', aliases: %w[me myself profile] do |p|
            p.register 'show', me.user_show, aliases: %w[sh view]
            p.register 'change', me.user_change, aliases: %w[ch chng update up modify mod]
            p.register 'password', me.user_password, aliases: %w[passwd pass pwd pw]
            p.register 'totp', me.user_totp, aliases: %w[code otp]
          end

          register 'users', aliases: %w[admins u] do |p|
            p.register 'list', me.users_list, aliases: %w[l all index]
            p.register 'change', me.users_change, aliases: %w[ch chng update up modify mod]
            p.register 'create', me.users_create, aliases: %w[make new n]
            p.register 'remove', me.users_remove, aliases: %w[rem r delete del d destroy]
          end

          register 'templates', aliases: %w[temps temp tmp t] do |p|
            p.register 'list', me.templates_list, aliases: %w[l all index]
            p.register 'change', me.templates_change, aliases: %w[ch chng update up modify mod]
          end

          register 'login', me.login, aliases: %w[signin authenticate auth]
          register 'logout', me.logout, aliases: %w[signout deauthenticate deauth unauthenticate unauth]
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pcli-0.1.1 lib/pcli/services/all_commands.rb
pcli-0.1.0 lib/pcli/services/all_commands.rb