Class: Explore::Cli::Runner
- Inherits:
-
Object
- Object
- Explore::Cli::Runner
- Defined in:
- lib/explore/cli.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
"https://exploremyprofile.com".freeze
- DEFAULT_LOGIN_POLL_INTERVAL =
1- DEFAULT_LOGIN_MAX_POLLS =
120
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(argv:, env:, stdout:, stderr:, stdin: $stdin, client_class: Client, config_store: nil, secret_prompt: nil, browser_launcher: nil, sleeper: nil) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(argv:, env:, stdout:, stderr:, stdin: $stdin, client_class: Client, config_store: nil, secret_prompt: nil, browser_launcher: nil, sleeper: nil) ⇒ Runner
Returns a new instance of Runner.
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/explore/cli.rb', line 134 def initialize(argv:, env:, stdout:, stderr:, stdin: $stdin, client_class: Client, config_store: nil, secret_prompt: nil, browser_launcher: nil, sleeper: nil) @argv = argv.dup @env = env @stdout = stdout @stderr = stderr @stdin = stdin @client_class = client_class @config_store = config_store || ConfigStore.new(env:) @secret_prompt = secret_prompt @browser_launcher = browser_launcher @sleeper = sleeper || ->(seconds) { sleep(seconds) } end |
Instance Method Details
#call ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/explore/cli.rb', line 147 def call command = argv.shift return emit_version if version_flag?(command) raise Error.new(usage, exit_code: 2) if blank_value?(command) case command when "version" emit_version when "setup" = (argv, require_input: false) execute_setup() when "register" = (argv, require_input: false) execute_register() when "login" = (argv, require_input: false, include_stored: false) execute_login() when "logout" = (argv, require_input: false, include_stored: false) removed = config_store.delete emit(output_for_logout(removed, )) when "whoami" = (argv, require_input: false) validate_whoami_scope!() response = client().get("/api/agent/v1/profile", params: scope_params()) emit(output_for_whoami(response, )) when "export" execute_export(argv) when "validate" execute_validate(argv) when "apply" execute_apply(argv) when "profile" execute_read(argv.shift, "/api/agent/v1/profile") when "content" subcommand = argv.shift return execute_read(subcommand, "/api/agent/v1/content") if subcommand == "list" return execute_create_draft if subcommand == "create-draft" return execute_propose_update if subcommand == "propose-update" raise Error.new(usage, exit_code: 2) when "drafts" subcommand = argv.shift return execute_read(subcommand, "/api/agent/v1/drafts") if subcommand == "list" return execute_draft_inspect if subcommand == "inspect" return execute_draft_apply if subcommand == "apply" return execute_draft_apply_preview if subcommand == "apply-preview" return execute_draft_update if subcommand == "update" return execute_draft_archive if subcommand == "archive" raise Error.new(usage, exit_code: 2) when "onboarding" execute_read(argv.shift, "/api/agent/v1/onboarding/status") when "manifest" execute_read(argv.shift, "/api/agent/v1/manifest/next_actions") when "notion" execute_read(argv.shift, "/api/agent/v1/notion/sync_status") when "publish" execute_read(argv.shift, "/api/agent/v1/publish/preview") else raise Error.new(usage, exit_code: 2) end 0 rescue Error => e stderr.puts(e.) e.exit_code end |