Sha256: 466931c832c3e07f0a26cd3eeba8b5634aab9c792b842fc2962e4c0ea0e24e48
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true require 'thor' require 'yaml' module GistUpdater class Commands < Thor package_name 'gist_updater' default_task :update class_option :yaml, type: :string, aliases: :y, desc: 'User definition YAML file', default: 'gist_updater.yml' class_option :user, type: :string, aliases: :u, desc: 'GitHub username' class_option :token, type: :string, aliases: :t, desc: 'GitHub personal access token' class_option :debug, type: :boolean, aliases: :d, desc: 'Debug mode', default: false desc 'update', 'Update your Gist files (default)' def update configs.each do |config| content = ContentFactory.build(user, access_token, config) if content.gist == content.local puts <<~EOS if options[:debug] There was no need to update `#{content.name}`. EOS else content.update end end end desc 'version', 'Display version' def version puts VERSION end private def configs @configs ||= YAML.load(IO.read(options[:yaml])) end def user @user ||= options[:user] || ENV['GISTUPDATER_USER'] || help_and_exit end def access_token @access_token ||= options[:token] || ENV['GISTUPDATER_ACCESS_TOKEN'] || help_and_exit end def help_and_exit help exit(1) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gist_updater-0.1.0 | lib/gist_updater/commands.rb |