Sha256: c983c07f5c2cadc75396ac3e70713ac7a20c8568d0dd0b75ae0200404ca18168
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
# frozen_string_literal: true require_relative 'git_crecord/diff' require_relative 'git_crecord/git' require_relative 'git_crecord/ui' require_relative 'git_crecord/ui/help_window' require_relative 'git_crecord/version' module GitCrecord def self.main(argv) if argv.include?('--version') puts VERSION true elsif argv.include?('--help') || argv.include?('-h') help true else run(with_untracked_files: untracked_files?(argv), reverse: reverse?(argv)) end end def self.untracked_files?(argv) return false if reverse?(argv) argv.include?('--untracked-files') || argv.include?('-u') end def self.reverse?(argv) argv.include?('--reverse') || argv.include?('-R') end def self.run(with_untracked_files: false, reverse: false) toplevel_dir = Git.toplevel_dir return false if toplevel_dir.empty? Dir.chdir(toplevel_dir) do files = Diff.create(reverse: reverse, untracked: with_untracked_files) return false if files.empty? UI::StatusBar.reverse = reverse result = UI.run(files) return result.call(reverse) == true if result.respond_to?(:call) true end end def self.help puts <<~HELP usage: git crecord [<options>] -u, --untracked-files -- show untracked files -R, --reverse -- unstage hunks --version -- show version information -h -- this help message in-program commands: #{UI::HelpWindow::CONTENT.gsub(/^/, ' ')} HELP end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git-crecord-1.2.0 | lib/git_crecord.rb |