Skip to content

Commit

Permalink
Better output when pushing / pulling
Browse files Browse the repository at this point in the history
  • Loading branch information
Intrepidd committed Mar 1, 2024
1 parent 7edeb4d commit 495b8c6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PATH
yamlfish (0.1.0.alpha1)
activesupport (>= 6)
faraday (~> 2.0)
rainbow (~> 3.1)
thor (~> 1.2)

GEM
Expand Down Expand Up @@ -36,6 +37,7 @@ GEM
mutex_m (0.2.0)
net-http (0.4.1)
uri
rainbow (3.1.1)
rake (13.0.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
Expand Down
1 change: 1 addition & 0 deletions lib/yamlfish/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require_relative "cli/push"
require_relative "cli/pull"
require "yaml"
require "rainbow"

module Yamlfish
module Cli
Expand Down
8 changes: 8 additions & 0 deletions lib/yamlfish/cli/pull.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,20 @@ def call
"Authorization": "Bearer #{Yamlfish::Cli.configuration.api_key}"
}
)

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

translations = JSON.parse(response.body)

if @inplace
replace_inplace(translations)
puts "Fetched translations in-place for locale #{Rainbow(@locale_identifier).magenta.bright}"
else
dump_translations(translations)
puts "Downloaded new translations for locale #{Rainbow(@locale_identifier).magenta.bright}"
end
end

Expand Down
6 changes: 5 additions & 1 deletion lib/yamlfish/cli/push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def call
"Authorization": "Bearer #{Yamlfish::Cli.configuration.api_key}"
}
)
puts response.status
if response.status == 201
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
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions yamlfish-cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "thor", "~> 1.2"
spec.add_dependency "activesupport", ">= 6"
spec.add_dependency "faraday", "~> 2.0"
spec.add_dependency "rainbow", "~> 3.1"

# For more information and examples about making a new gem, checkout our
# guide at: https://bundler.io/guides/creating_gem.html
Expand Down

0 comments on commit 495b8c6

Please sign in to comment.