Sha256: 05f190a930ba09380028fd226809041f1f9a909c1a402ed06737c3697e7feb76

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require "shelly/cli/command"

module Shelly
  module CLI
    class Config < Command
      include Thor::Actions
      include Helpers

      desc "list", "List configuration files"
      def list
        logged_in?
        say_error "No Cloudfile found" unless Cloudfile.present?
        cloudfile = Cloudfile.new
        cloudfile.clouds.each do |cloud|
          @app = App.new(cloud)
          begin
            configs = @app.configs
            unless configs.empty?
              say "Configuration files for #{cloud}", :green
              user_configs = @app.user_configs
              unless user_configs.empty?
                say "Custom configuration files:"
                user_configs.each { |config| say " * #{config["path"]}" }
              else
                say "You have no custom configuration files."
              end
              shelly_configs = @app.shelly_generated_configs
              unless shelly_configs.empty?
                say "Following files are created by Shelly Cloud:"
                shelly_configs.each { |config| say " * #{config["path"]}" }
              end
            else
              say "Cloud #{cloud} has no configuration files"
            end
          rescue Client::APIError => e
            if e.unauthorized?
              say_error "You have no access to '#{@app.code_name}' cloud defined in Cloudfile"
            else
              say_error e.message
            end
          end
        end
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shelly-0.0.32 lib/shelly/cli/config.rb
shelly-0.0.31 lib/shelly/cli/config.rb