Skip to content

Commit

Permalink
Updates aliases to add wrapper language
Browse files Browse the repository at this point in the history
  • Loading branch information
bougyman committed Feb 5, 2024
1 parent a245168 commit 6dea5e3
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
linear-cli (0.5.4)
linear-cli (0.6.1)
base64 (~> 0.2)
dry-cli (~> 1.0)
dry-cli-completion (~> 1.0)
Expand Down
4 changes: 1 addition & 3 deletions exe/lc
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'linear'
Rubyists::Linear::L :cli
Dry::CLI.new(Rubyists::Linear::CLI).call
exec File.join(__dir__, 'lc.sh'), *ARGV
2 changes: 2 additions & 0 deletions exe/lc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
exec linear-cli issue list "$@"
4 changes: 2 additions & 2 deletions exe/lclose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ then
printf "This wrapper adds the --close option to the 'issue update' command.\n" >&2
printf "It is used to close one or many issues. The issues are specified by their ID/slugs.\n" >&2
printf "For closing multiple issues, you really want to pass --reason so you do not get prompted for each issue.\n\n" >&2
exec lc issue update --help
exec linear-cli issue update --help
fi
exec lc issue update --close "$@"
exec linear-cli issue update --close "$@"
2 changes: 1 addition & 1 deletion exe/lcls.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
exec lc i ls "$@"
exec linear-cli issue list "$@"
2 changes: 1 addition & 1 deletion exe/lcreate.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
exec lc issue create "$@"
exec linear-cli issue create "$@"
6 changes: 6 additions & 0 deletions exe/linear-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'linear'
Rubyists::Linear::L :cli
Dry::CLI.new(Rubyists::Linear::CLI).call
7 changes: 4 additions & 3 deletions lib/linear/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ def self.register_subcommands!(command, name, klass)
end
end

def self.load_and_register!(command)
logger.debug "Registering #{command}"
def self.load_and_register!(command, description: nil)
description ||= command::DESCRIPTION
logger.debug "Registering #{command} #{description}"
name = command.name.split('::').last.downcase
command_aliases = command::ALIASES[name.to_sym] || []
register name, aliases: Array(command_aliases) do |cmd|
register name, description:, aliases: Array(command_aliases) do |cmd|
register_subcommands! cmd, name, command
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/linear/commands/issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module CLI
# should be included in any command that deals with issues
module Issue
include CLI::SubCommands

DESCRIPTION = 'Manage issues'

# Aliases for Issue commands
ALIASES = {
create: %w[c new add], # aliases for the create command
Expand All @@ -19,6 +22,7 @@ module Issue
issue: %w[i issues] # aliases for the main issue command itself
}.freeze


def issue_comment(issue, comment)
issue.add_comment(comment)
prompt.ok("Comment added to #{issue.identifier}")
Expand Down
2 changes: 2 additions & 0 deletions lib/linear/commands/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ module Team
list: %w[ls l], # aliases for the list command
team: %w[t teams] # aliases for the main team command itself
}.freeze

DESCRIPTION = 'Manage teams'
end
end
end
Expand Down

0 comments on commit 6dea5e3

Please sign in to comment.