Module: SmilyCli::CLIOptions

Defined in:
lib/smily_cli/cli_options.rb

Overview

Declares the reusable Thor option groups so every command exposes the same connection and output flags with identical wording. Because Thor does not forward a parent command's class_options to registered subcommands, each command class opts in by calling these helpers in its body.

Class Method Summary collapse

Class Method Details

.connection(thor) ⇒ void

This method returns an undefined value.

Connection / global behavior flags (token, profile, base URL, verbosity).

Parameters:

  • thor (Class<Thor>)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/smily_cli/cli_options.rb', line 15

def connection(thor)
  thor.class_option :profile, type: :string, banner: "NAME",
                              desc: "Config profile to use (env: SMILY_PROFILE)"
  thor.class_option :token, type: :string, banner: "TOKEN",
                            desc: "OAuth access token (env: SMILY_TOKEN)"
  thor.class_option :base_url, type: :string, banner: "URL",
                               desc: "API base URL (default: https://www.bookingsync.com)"
  thor.class_option :account_id, type: :string, banner: "ID",
                                 desc: "Scope requests to an account (for client-credentials tokens)"
  thor.class_option :max_pages, type: :numeric, banner: "N",
                                desc: "Cap auto-pagination at N pages (default 1000)"
  thor.class_option :retry, type: :numeric, banner: "N",
                            desc: "Retry 429s up to N times, honoring rate-limit reset"
  thor.class_option :verbose, type: :boolean, aliases: "-v",
                              desc: "Log HTTP requests/responses to stderr"
  thor.class_option :quiet, type: :boolean, aliases: "-q",
                            desc: "Suppress status messages"
  thor.class_option :no_color, type: :boolean,
                               desc: "Disable ANSI color"
end

.mcp(thor) ⇒ void

This method returns an undefined value.

MCP-mode connection flags. Shares profile/base-url/account/verbosity with connection but swaps the REST token for the dedicated MCP credential.

Parameters:

  • thor (Class<Thor>)


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/smily_cli/cli_options.rb', line 41

def mcp(thor)
  thor.class_option :profile, type: :string, banner: "NAME",
                              desc: "Config profile to use (env: SMILY_PROFILE)"
  thor.class_option :mcp_token, type: :string, banner: "TOKEN",
                                desc: "MCP access token (env: SMILY_MCP_TOKEN)"
  thor.class_option :mcp_url, type: :string, banner: "URL",
                              desc: "MCP server endpoint (default: <base-url>/mcp)"
  thor.class_option :base_url, type: :string, banner: "URL",
                               desc: "Base URL used to derive the default MCP endpoint"
  thor.class_option :account_id, type: :string, banner: "ID",
                                 desc: "Scope tool calls to an account"
  thor.class_option :verbose, type: :boolean, aliases: "-v",
                              desc: "Log MCP traffic to stderr"
  thor.class_option :quiet, type: :boolean, aliases: "-q",
                            desc: "Suppress status messages"
  thor.class_option :no_color, type: :boolean, desc: "Disable ANSI color"
end

.output(thor) ⇒ void

This method returns an undefined value.

Output-shaping flags (format and field selection).

Parameters:

  • thor (Class<Thor>)


63
64
65
66
67
68
# File 'lib/smily_cli/cli_options.rb', line 63

def output(thor)
  thor.class_option :output, type: :string, aliases: "-o", banner: "FORMAT",
                             desc: "Output: table, json, yaml, csv, ndjson (default: table on a TTY, else json)"
  thor.class_option :fields, type: :array, banner: "a b c",
                             desc: "Limit fields/columns (sparse fieldset)"
end