Sha256: c797b7d76c05d15470bef71554a86242ec8bdc2e1d8283fb20765b604957bdae

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

module Fontist
  class ConfigCLI < Thor
    include CLI::ClassOptions

    STATUS_SUCCESS = 0

    desc "show", "Show values of the current config"
    def show
      handle_class_options(options)
      values = Config.instance.custom_values
      Fontist.ui.success("Current config:")
      Fontist.ui.success(format_hash(values))
      STATUS_SUCCESS
    end

    desc "set KEY VALUE", "Set the KEY attribute to VALUE in the current config"
    def set(key, value)
      handle_class_options(options)
      Config.instance.set(key, value)
      Fontist.ui.success("'#{key}' set to '#{value}'.")
      STATUS_SUCCESS
    end

    desc "delete KEY", "Delete the KEY attribute from the current config"
    def delete(key)
      handle_class_options(options)
      Config.instance.delete(key)
      Fontist.ui.success(
        "'#{key}' reset to default ('#{Config.instance.default_value(key)}').",
      )
      STATUS_SUCCESS
    end

    private

    def format_hash(hash)
      YAML.dump(hash).gsub(/^---.*$/, "").strip
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fontist-1.18.2 lib/fontist/config_cli.rb