Class: Pike13::CLI::Commands::Base
- Inherits:
-
Thor
- Object
- Thor
- Pike13::CLI::Commands::Base
- Includes:
- ThorNestedSubcommand
- Defined in:
- lib/pike13/cli/commands/base.rb
Direct Known Subclasses
Account, Account::Business, Account::Confirmation, Account::Password, Account::Person, Desk, Desk::Appointment, Desk::Booking, Desk::Business, Desk::CustomField, Desk::Event, Desk::EventOccurrence, Desk::EventOccurrenceNote, Desk::EventOccurrenceVisit, Desk::EventOccurrenceWaitlistEntry, Desk::FormOfPayment, Desk::Invoice, Desk::Location, Desk::MakeUp, Desk::Note, Desk::Pack, Desk::PackProduct, Desk::Payment, Desk::Person, Desk::PersonPlan, Desk::PersonVisit, Desk::PersonWaitlistEntry, Desk::PersonWaiver, Desk::Plan, Desk::PlanProduct, Desk::Punch, Desk::Refund, Desk::RevenueCategory, Desk::SalesTax, Desk::Service, Desk::StaffMember, Desk::Visit, Desk::WaitlistEntry, Front, Front::Appointment, Front::Booking, Front::Branding, Front::Business, Front::Event, Front::EventOccurrence, Front::EventOccurrenceNote, Front::EventOccurrenceWaitlistEligibility, Front::FormOfPayment, Front::Location, Front::Person, Front::PersonPlan, Front::PersonVisit, Front::PersonWaitlistEntry, Front::PersonWaiver, Front::PlanProduct, Front::PlanTerms, Front::Service, Report, Report::Clients, Report::Enrollments, Report::EventOccurrenceStaffMembers, Report::EventOccurrences, Report::InvoiceItemTransactions, Report::InvoiceItems, Report::Invoices, Report::MonthlyBusinessMetrics, Report::Pays, Report::PersonPlans, Report::StaffMembers, Report::Transactions
Class Method Summary collapse
-
.base_usage ⇒ Object
Auto-generate base_usage from class name.
-
.format_options ⇒ Object
Helper to add format options to commands.
-
.handle_argument_error(task, error, _type) ⇒ Object
Override help to show command-specific options.
-
.printable_commands(*args) ⇒ Object
Override printable_commands to hide redundant help command from listings.
Methods included from ThorNestedSubcommand
Class Method Details
.base_usage ⇒ Object
Auto-generate base_usage from class name
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pike13/cli/commands/base.rb', line 31 def self.base_usage # Convert class name like Pike13::CLI::Commands::Report::Clients # to "report clients" namespace_parts = name.split("::")[3..] # Skip Pike13::CLI::Commands if namespace_parts && namespace_parts.length > 1 # For nested classes like Report::Clients namespace_parts.map(&:downcase).join(" ") elsif namespace_parts&.length == 1 # For top-level namespace classes namespace_parts.first.downcase else "" end end |
.format_options ⇒ Object
Helper to add format options to commands
47 48 49 50 51 52 |
# File 'lib/pike13/cli/commands/base.rb', line 47 def self. option :format, type: :string, default: "json", desc: "Output format (json, table, csv)" option :compact, type: :boolean, default: false, desc: "Compact JSON output" option :color, type: :boolean, default: false, desc: "Colorize table output" option :progress, type: :boolean, default: false, desc: "Show progress indicator" end |
.handle_argument_error(task, error, _type) ⇒ Object
Override help to show command-specific options
23 24 25 26 27 28 |
# File 'lib/pike13/cli/commands/base.rb', line 23 def self.handle_argument_error(task, error, _type) puts "Error: #{error.}" puts puts "Run '#{basename} #{base_usage} #{task.name} --help' for more information." exit 1 end |
.printable_commands(*args) ⇒ Object
Override printable_commands to hide redundant help command from listings
16 17 18 19 20 |
# File 'lib/pike13/cli/commands/base.rb', line 16 def self.printable_commands(*args) result = super # Remove the help command from listings since it's redundant when using -h/--help result.reject { |item| item.first.include?("help [COMMAND]") } end |