Module: ShapeupCli
- Defined in:
- lib/shapeup_cli.rb,
lib/shapeup_cli/auth.rb,
lib/shapeup_cli/client.rb,
lib/shapeup_cli/config.rb,
lib/shapeup_cli/output.rb,
lib/shapeup_cli/commands.rb,
lib/shapeup_cli/commands/auth.rb,
lib/shapeup_cli/commands/base.rb,
lib/shapeup_cli/commands/orgs.rb,
lib/shapeup_cli/commands/cycle.rb,
lib/shapeup_cli/commands/login.rb,
lib/shapeup_cli/commands/setup.rb,
lib/shapeup_cli/commands/tasks.rb,
lib/shapeup_cli/commands/issues.rb,
lib/shapeup_cli/commands/logout.rb,
lib/shapeup_cli/commands/scopes.rb,
lib/shapeup_cli/commands/search.rb,
lib/shapeup_cli/commands/my_work.rb,
lib/shapeup_cli/commands/pitches.rb,
lib/shapeup_cli/commands/comments.rb,
lib/shapeup_cli/commands/config_cmd.rb
Defined Under Namespace
Modules: Auth, Commands, Config, Output Classes: Client
Constant Summary collapse
- VERSION =
"0.3.2"- DEFAULT_HOST =
"https://shapeup.cc"- EXIT_OK =
Exit codes
0- EXIT_USAGE =
1- EXIT_NOT_FOUND =
2- EXIT_AUTH =
3- EXIT_PERMISSION =
4- EXIT_API_ERROR =
5- EXIT_RATE_LIMIT =
6- EXIT_INTERRUPTED =
130- COMMAND_MAP =
{ "orgs" => Commands::Orgs, "pitches" => Commands::Pitches, "cycle" => Commands::Cycle, "scopes" => Commands::Scopes, "tasks" => Commands::Tasks, "issues" => Commands::Issues, "my-work" => Commands::MyWork, "search" => Commands::Search, "auth" => Commands::Auth, "config" => Commands::ConfigCmd, "setup" => Commands::Setup, "comments" => Commands::Comments }.freeze
Class Method Summary collapse
Class Method Details
.run(argv) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/shapeup_cli.rb', line 47 def self.run(argv) args = argv.dup # Top-level: shapeup --agent --help if args.include?("--agent") && args.include?("--help") command = (args - [ "--agent", "--help" ]).first if command && COMMAND_MAP[command] puts JSON.pretty_generate(COMMAND_MAP[command].) else puts JSON.pretty_generate() end return end command = args.shift case command when "login" then Commands::Login.run(args) when "logout" then Commands::Logout.run(args) when "auth" then Commands::Auth.run(args) when "orgs" then Commands::Orgs.run(args) when "pitches" then Commands::Pitches.run(args) when "pitch" then Commands::Pitches.run(["show"] + args) when "cycle" then Commands::Cycle.run(args) when "cycles" then Commands::Cycle.run(["list"] + args) when "scopes" then Commands::Scopes.run(args) when "tasks" then Commands::Tasks.run(args) when "todo" then Commands::Tasks.run(["create"] + args) when "done" then Commands::Tasks.run(["complete"] + args) when "issues" then Commands::Issues.run(args) when "issue" then Commands::Issues.run(["show"] + args) when "watching" then Commands::Issues.run(["watching"] + args) when "comments" then Commands::Comments.run(args) when "my-work", "me" then Commands::MyWork.run(args) when "search" then Commands::Search.run(args) when "config" then Commands::ConfigCmd.run(args) when "setup" then Commands::Setup.run(args) when "commands" then Commands.list_commands when "version", "-v", "--version" puts "shapeup #{VERSION}" when "help", "-h", "--help", nil Commands.help else $stderr.puts "Unknown command: #{command}" $stderr.puts "Run 'shapeup help' for usage" exit 1 end rescue Client::AuthError => e $stderr.puts "Not authenticated. Run 'shapeup login' first." exit EXIT_AUTH rescue Client::NotFoundError => e $stderr.puts "Not found: #{e.}" exit EXIT_NOT_FOUND rescue Client::PermissionError => e $stderr.puts "Access denied: #{e.}" exit EXIT_PERMISSION rescue Client::RateLimitError => e $stderr.puts "Rate limited — please wait and try again." exit EXIT_RATE_LIMIT rescue Client::ApiError => e $stderr.puts "Error: #{e.}" exit EXIT_API_ERROR rescue Interrupt $stderr.puts "\nAborted." exit EXIT_INTERRUPTED end |
.top_level_metadata ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/shapeup_cli.rb', line 114 def self. { command: "shapeup", version: VERSION, short: "Manage ShapeUp pitches, scopes, tasks, issues, and cycles from the terminal", commands: COMMAND_MAP.map { |name, klass| { name: name, **klass..slice(:short, :path) } }, shortcuts: { "pitch <id>" => "pitches show <id>", "cycles" => "cycle list", "todo \"...\"" => "tasks create \"...\"", "done <id>" => "tasks complete <id>", "issue <id>" => "issues show <id>", "watching" => "issues watching", "me" => "my-work" }, inherited_flags: [ { name: "org", type: "string", usage: "Organisation ID or name" }, { name: "json", type: "bool", usage: "Full JSON envelope with breadcrumbs" }, { name: "md", type: "bool", usage: "Markdown output" }, { name: "agent", type: "bool", usage: "Raw JSON data only (for AI agents)" } ] } end |