Skip to content

Commit

Permalink
Better error management
Browse files Browse the repository at this point in the history
  • Loading branch information
Intrepidd committed Aug 28, 2024
1 parent 17946a0 commit aaea347
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions exe/yamlfish
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class YamlfishExe < Thor
option :branch, type: :string, default: "main"
def push(locale)
Yamlfish::Cli::Push.new(locale, branch: options[:branch]).call
rescue Errno::ENOENT => e
puts Rainbow("Could not push: #{e.message}").red.bright
exit 1
end

desc "pull", "Pulls translations from yamlfish"
Expand All @@ -17,6 +20,9 @@ class YamlfishExe < Thor
option :branch, type: :string, default: "main"
def pull(locale)
Yamlfish::Cli::Pull.new(locale, inplace: options[:inplace], force_update: options[:force_update], branch: options[:branch]).call
rescue Errno::ENOENT => e
puts Rainbow("Could not pull: #{e.message}").red.bright
exit 1
end

desc "version", "Prints the version"
Expand Down
2 changes: 1 addition & 1 deletion lib/yamlfish/cli/pull.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def call

if response.status != 200
puts Rainbow("Failed to pull, unexpected HTTP status #{response.status}").red.bright
return
exit 1
end

translations = JSON.parse(response.body)
Expand Down
1 change: 1 addition & 0 deletions lib/yamlfish/cli/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def call
puts "Successfully pushed translations for locale #{Rainbow(@locale_identifier).magenta.bright} on branch #{Rainbow(@branch).magenta.bright}"
else
puts Rainbow("Failed to push, unexpected HTTP status #{response.status}").red.bright
exit 1
end
end
end
Expand Down

0 comments on commit aaea347

Please sign in to comment.