Skip to content

Commit

Permalink
Improve type documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
apainintheneck committed Feb 20, 2024
1 parent 34a6592 commit b9c0f4b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/atlasq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def self.failed!
@failed = true
end

# @return [Boolean]
def self.failed?
!!@failed
end
Expand Down
4 changes: 4 additions & 0 deletions lib/atlasq/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ module Command
# @param args [Array<String>]
Options = Struct.new(:command, :args, keyword_init: true)

# @param args [Array<String>] command line arguments
# @return [Atlasq::Command::Options]
def self.parse(args)
command = parse_command(args.first)
args.shift unless command.to_s == "Atlasq::Command::Any"
Expand All @@ -22,6 +24,8 @@ def self.parse(args)
Options.new(command: command, args: args).freeze
end

# @param command [String]
# @return [Atlasq::Command::Base]
def self.parse_command(command)
case command
when "-c", "--country", "--countries"
Expand Down
1 change: 1 addition & 0 deletions lib/atlasq/command/any.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
module Atlasq
module Command
class Any < Base
# @return [String]
def content
search_terms.map do |term|
if (country = Data.country(term))
Expand Down
1 change: 1 addition & 0 deletions lib/atlasq/command/money.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
module Atlasq
module Command
class Money < Base
# @return [String]
def content
if search_terms.empty?
currencies = Data.all_currencies
Expand Down
1 change: 1 addition & 0 deletions lib/atlasq/command/region.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
module Atlasq
module Command
class Region < Base
# @return [String]
def content
if search_terms.empty?
subregions = Data.all_subregions
Expand Down
2 changes: 2 additions & 0 deletions lib/atlasq/format.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def self.currencies(currencies, partial_match: false)
end
end

# @param country_code [String]
# @return [String]
def self.one_line_currency(currency_code)
Cache
.get("formatted_output/one_line_currency.json")
Expand Down
4 changes: 4 additions & 0 deletions lib/atlasq/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Atlasq
module Shell
SKIP_PAGER = %i[usage version].freeze

# @param [Array<String>] command line arguments
def self.start!(args = ARGV)
warn "DEBUG: args: #{args}" if DEBUG
options = Command.parse(args)
Expand All @@ -24,6 +25,9 @@ def self.start!(args = ARGV)

DEFAULT_SHELL_HEIGHT = 24

# @param options [Atlasq::Command::Options]
# @param content [String]
# @return [Boolean]
def self.use_pager?(options, content)
$stdout.tty? &&
options.command.to_pager? &&
Expand Down

0 comments on commit b9c0f4b

Please sign in to comment.