require 'clamp' require 'tempfile' require 'shellwords' require 'rugged' module Gisha class ReceiveCommand < Clamp::Command parameter 'KEY_ID', 'id to identify the key' def execute Commands::Receive.new(key_id).exec end end class AddKeyCommand < Clamp::Command parameter 'ID', 'id to identify the key' parameter 'KEY', 'public key that was provided to the server' parameter 'AUTH_FILE', 'file containing public keys for public key authentication;' def execute Commands::Key.new(auth_file, id, key).add end end class DeleleteKeyCommand < Clamp::Command parameter 'ID', 'id to identify the key' parameter 'AUTH_FILE', 'file containing public keys for public key authentication;' def execute Commands::Key.new(auth_file, id).del end end class CreateRepositoryCommand < Clamp::Command parameter 'PATH', 'path to create repository' def execute Rugged::Repository.init_at(path, :bare) end end class DeleteRepositoryCommand < Clamp::Command parameter 'PATH', 'path to delete repository' def execute puts "delete repository #{path}" end end class CLI < Clamp::Command subcommand 'keys:add', 'add new key', AddKeyCommand subcommand 'keys:del', 'delete key', DeleleteKeyCommand subcommand 'repositories:create', 'create repository', CreateRepositoryCommand subcommand 'repositories:delete', 'delete repository', DeleteRepositoryCommand subcommand 'receive', 'receive what is pushed into the repository', ReceiveCommand end end