Sha256: e422533f34275e742c4492562ed030495933c0be80dd64ed171c018e7c03d43d

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

command :config do |c|
  c.syntax = 'brief config [options]'
  c.description = 'manipulate brief configuration settings'

  c.action do |args, options|
    Brief::Configuration.initialize!

    # Setting a value manually
    if args.first == 'set'
      args.slice(1, args.length).map(&:strip).each do |pair|
        key, value = pair.split('=')
        Brief.configuration.set(key, value, false)
      end

      Brief.configuration.save!
    end

    if args.empty? && !(Brief.config.github_username || Brief.config.github_token)
      args.push "github"
    end

    if args.first == "github"
      username = ask("What is your github username: ", String)

      say "If you haven't generated a personal access token yet, do so here: https://github.com/settings/tokens/new"
      access_token = ask("Enter your private access token: ")

      if username
        Brief.config.set "github_username", username
      end

      if access_token
        # TODO
        # We could validate the token for them.
        Brief.config.set "github_token", access_token
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brief-0.0.5 lib/brief/cli/commands/config.rb
brief-0.0.4 lib/brief/cli/commands/config.rb
brief-0.0.3 lib/brief/cli/commands/config.rb
brief-0.0.2 lib/brief/cli/commands/config.rb