Sha256: 88879a9701f6a942d2c46fcfbdb7e0ba8d52ef7c9fe54632ffbbb2123e793b29

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env ruby

lib = File.expand_path('../lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'git/superproject'

if (command = ARGV.shift)&.start_with? '++'
  name = command[2..-1]
  command = nil
end

# TODO: acquire flock on "~/.git/multi/superprojects.config"

case (command ||= ARGV.shift)
when /\A--/
  case command
  when '--version' then Git::Superproject::Commands.version
  when '--help'    then Git::Superproject::Commands.help
  else
    config = Git::Superproject::Config.from(Git::SUPERPROJECTS_CONFIG)
    case command
    when '--config' then puts config.to_json
    else
      unless name
        warn 'No superproject specified... aborting!'
        exit(-1)
      end
      case command
      when '--list'   then config.list(name)
      when '--add'    then config.add(name, *ARGV)
      when '--remove' then config.remove(name, *ARGV)
      when '--edit'
        finder = 'fzf --print0 --multi --border --height=50%'
        candidates = ARGF.readlines.map(&:strip) # repos to select from...
        config.edit(name, finder, candidates)
      else
        abort \
          "Unknown 'git superproject' command: #{command}\n\n" \
          '(use --help/-h to list all available commands)'
      end
      config.save(Git::SUPERPROJECTS_CONFIG)
    end
  end
when nil, '', '-h'
  Git::Superproject::Commands.help
end

# TODO: release flock on "~/.git/multi/superprojects.config"

# That's all Folks!

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
git-superproject-1.0.0 exe/git-superproject