<commit_before># encoding: utf-8

module GithubCLI
  class CLI < Thor
    include Thor::Actions
    require 'github_cli/subcommands'

    def initialize(*args)
      super
      the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
      GithubCLI.ui = UI.new(the_shell)
      GithubCLi.ui.debug! if options["verbose"]
      options["no-pager"] ? Pager.disable : Pager.enable
      Terminal.print_program_name
    end

    map "repository" => :repo,
        "reference"  => :ref,
        "is" => :issue,
        "-v" => :version,
        "ls" => :list

    class_option :config, :type => :string,
                 :desc => "Configuration file.", :banner => "Config file name",
                 :default => ".githubrc"
    class_option :oauth, :type => :string, :aliases => '-a',
                 :desc => 'Authentication token.',
                 :banner => 'Set authentication token'
    class_option "no-color", :type => :boolean,
                 :banner => "Disable colorization in output."
    class_option "no-pager", :type => :boolean,
                 :banner => "Disable pagination of the output."
    class_option :verbose, :type => :boolean,
                 :banner => "Enable verbose output mode."

    desc 'init', 'Generates a configuration file in your home directory'
    long_desc <<-DESC
      Initializes a configuration file where you can set default options for
      interacting with GitHub API. Both global and per-command options can be
      specified. These defaults override the bult-in defaults and allow you to
      omit commonly used command line options.
    DESC
    method_option :force, :type => :boolean, :default => false, :aliases => "-f",
                  :banner => "Overwrite configuration file. "
    def init(filename=nil)
      if filename.nil? || filename =~ /^\//
        @config_filename = options[:config]
      else
        @config_filename = filename
      end

      # config = Config.new(@config_filename)
      if File.exists?(GithubCLI.config.path) && !options[:force]
        GithubCLI.ui.error "Not overwritting existing config file #{GithubCLI.config.path}, use --force to override."
        exit 1
      end

      oauth_token = ask "Please specify your GitHub Authentication Token (register on github.com to get it):"
      GithubCLI.config.save({'oauth_token' => oauth_token, 'basic_auth' => nil })
      GithubCLI.ui.confirm "Writing new configuration file to #{GithubCLI.config.path}"
    end

    desc 'list <pattern>', 'List all available commands limited by pattern'
    def list(pattern="")
      pattern = /^#{pattern}.*$/i
      Terminal.print_commands pattern
    end

    desc 'version', 'Display Github CLI version.'
    def version
      say "Github CLI #{GithubCLI::VERSION}"
    end

  end # CLI
end # GithubCLI
<commit_msg>Add new global option for setting pager.<commit_after># encoding: utf-8

module GithubCLI
  class CLI < Thor
    include Thor::Actions
    require 'github_cli/subcommands'

    def initialize(*args)
      super
      the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
      GithubCLI.ui = UI.new(the_shell)
      GithubCLi.ui.debug! if options["verbose"]
      options["no-pager"] ? Pager.disable : Pager.enable
      Terminal.print_program_name
    end

    map "repository" => :repo,
        "reference"  => :ref,
        "is" => :issue,
        "-v" => :version,
        "ls" => :list

    class_option :config, :type => :string,
                 :desc => "Configuration file.", :banner => "Config file name",
                 :default => ".githubrc"
    class_option :oauth, :type => :string, :aliases => '-a',
                 :desc => 'Authentication token.',
                 :banner => 'Set authentication token'
    class_option "no-color", :type => :boolean,
                 :desc => "Disable colorization in output."
    class_option "no-pager", :type => :boolean,
                 :desc => "Disable pagination of the output."
    class_option :pager, :type => :string, :aliases => '-p',
                 :desc => "Command to be used for paging. Command can have options after it i.e. 'less -r'. Defaults to common pagers i.e. less if detected.",
                 :banner => "less, more etc..."
    class_option :verbose, :type => :boolean,
                 :desc => "Enable verbose output mode."

    desc 'init', 'Generates a configuration file in your home directory'
    long_desc <<-DESC
      Initializes a configuration file where you can set default options for
      interacting with GitHub API. Both global and per-command options can be
      specified. These defaults override the bult-in defaults and allow you to
      omit commonly used command line options.
    DESC
    method_option :force, :type => :boolean, :default => false, :aliases => "-f",
                  :banner => "Overwrite configuration file. "
    def init(filename=nil)
      if filename.nil? || filename =~ /^\//
        @config_filename = options[:config]
      else
        @config_filename = filename
      end

      # config = Config.new(@config_filename)
      if File.exists?(GithubCLI.config.path) && !options[:force]
        GithubCLI.ui.error "Not overwritting existing config file #{GithubCLI.config.path}, use --force to override."
        exit 1
      end

      oauth_token = ask "Please specify your GitHub Authentication Token (register on github.com to get it):"
      GithubCLI.config.save({'oauth_token' => oauth_token, 'basic_auth' => nil })
      GithubCLI.ui.confirm "Writing new configuration file to #{GithubCLI.config.path}"
    end

    desc 'list <pattern>', 'List all available commands limited by pattern'
    def list(pattern="")
      pattern = /^#{pattern}.*$/i
      Terminal.print_commands pattern
    end

    desc 'version', 'Display Github CLI version.'
    def version
      say "Github CLI #{GithubCLI::VERSION}"
    end

  end # CLI
end # GithubCLI

{'fraction_non_alphanumeric': 0.12003381234150465, 'fraction_numerical': 0.000676246830092984, 'mean_word_length': 2.5382775119617227, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '473591', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1665, 'n_words': 536}