Sha256: 7615db924ce0c48a4258023fbfa1eeafa27270d5afdf8321905f536a41a94379

Contents?: true

Size: 880 Bytes

Versions: 3

Compression:

Stored size: 880 Bytes

Contents

# coding: utf-8
module Fir
  class Cli
    desc 'profile', '切换配置文件'
    option :delete, :aliases => '-d', :desc => '删除指定的配置文件', :type => :boolean
    output_options
    def profile(prof)
      if prof == 'global'
        _puts '! 不能使用 global 作为配置文件名'
        exit 1
      end
      prof = "#{prof}.yaml"
      if options[:delete]
        _puts "> 正在删除配置文件:#{prof}"
        @uconfig.delete prof
      else
        if _profile == prof
          _puts "! #{Paint["你正在使用该配置:#{prof}", :red]}"
          exit 1
        end
        _puts "> 正在使用配置文件:#{_profile}"
        _puts "> 即将替换为:#{prof}"
        @global_config['profile'] = prof
        @global_config.save
        _load_config
        _puts "> 已替换为:#{prof}"
        config
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fir-cli-0.2.0 lib/fir-cli-commands/00-profile.rb
fir-cli-0.1.9 lib/fir-cli-commands/00-profile.rb
fir-cli-0.1.8 lib/fir-cli-commands/profile.rb