103 lines
2.7 KiB
Crystal
103 lines
2.7 KiB
Crystal
|
|
require "option_parser"
|
|
|
|
module AutoBoard
|
|
class Cli
|
|
def initialize
|
|
@options = {} of Symbol => (String|Bool)
|
|
end
|
|
|
|
def parse_args(args : Array(String))
|
|
self.parser.parse(args)
|
|
@options
|
|
end
|
|
|
|
def parser() : OptionParser
|
|
parser = OptionParser.new do |opts|
|
|
opts.banner = "Usage: autoboard [options]"
|
|
|
|
opts.on("board", "Manage boards", &board_parser(opts))
|
|
opts.on("host", "Manage hosts", &host_parser(opts))
|
|
opts.on("template", "Manage templates", &template_parser(opts))
|
|
opts.on("workspace", "Manage workspaces", &workspace_parser(opts))
|
|
|
|
opts.on("-p", "--project PROJECT_ID", "Choose a project for the board") do |project_id|
|
|
@options[:project] = project_id
|
|
end
|
|
|
|
opts.on("-h", "--help", "Show this help") do
|
|
puts opts
|
|
exit
|
|
end
|
|
opts
|
|
end
|
|
end
|
|
|
|
def workspace_parser(opts : OptionParser)
|
|
->(value : String) do
|
|
opts.banner = "Usage: autoboard workspace [options]"
|
|
end
|
|
end
|
|
|
|
def host_parser(opts : OptionParser)
|
|
->(value : String) do
|
|
opts.banner = "Usage: autoboard host [options]"
|
|
end
|
|
end
|
|
|
|
def board_parser(opts : OptionParser)
|
|
->(value : String) do
|
|
opts.banner = "Usage: autoboard board [options]"
|
|
end
|
|
end
|
|
|
|
def template_column_parser(opts : OptionParser)
|
|
->(value : String) do
|
|
opts.on("create", "Add a new list to the template") do
|
|
opts.on("--label LABEL_ID", "Assign label LABEL_ID to the list") do |label_name|
|
|
@options[:label_name] = label_name
|
|
end
|
|
|
|
opts.on("--open", "Assign open tasks to the list") do |label_name|
|
|
end
|
|
|
|
opts.on("--closed", "Assign closed tasks to the list") do |label_name|
|
|
end
|
|
end
|
|
|
|
opts.on("destroy", "Remove a list from the template") do
|
|
end
|
|
|
|
opts.on("-c", "--column LIST_ID", "ID of the column") do |column_id|
|
|
@options[:column_id] = column_id
|
|
end
|
|
end
|
|
end
|
|
|
|
def template_parser(opts : OptionParser)
|
|
->(value : String) do
|
|
opts.banner = "Usage: autoboard template [options]"
|
|
|
|
opts.on("create", "Create a new template") do
|
|
end
|
|
|
|
opts.on("column", "Manage templates columns", &template_column_parser(opts))
|
|
|
|
opts.on("list", "List templates") do
|
|
end
|
|
|
|
opts.on("inspect", "Inspect a template") do
|
|
end
|
|
|
|
opts.on("destroy", "Destroy a new template") do
|
|
end
|
|
|
|
opts.on("-t", "--template TEMPLATE_ID", "ID of the template") do |template_id|
|
|
@options[:template_id] = template_id
|
|
end
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|