lib/gisha/cli.rb in gisha-0.0.2 vs lib/gisha/cli.rb in gisha-0.0.3

- old
+ new

@@ -1,29 +1,63 @@ require 'clamp' +require 'tempfile' +require 'shellwords' +require 'rugged' + module Gisha - class AuthCommand < Clamp::Command - parameter 'USER', 'username that was provided to the server' + 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 - puts "authenticate #{user} with #{key}" + Commands::Key.new(auth_file, id, key).add end end - class ReceiveCommand < Clamp::Command - parameter 'PATH', 'path of the repo that was pushed to' - parameter 'COMMIT', 'SHA of the commit that was pushed to master' + class DeleleteKeyCommand < Clamp::Command + parameter 'ID', 'id to identify the key' + parameter 'AUTH_FILE', 'file containing public keys for public key authentication;' def execute - puts "received #{commit} for repository #{path}" + 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 'auth', 'Authenticate user', AuthCommand - subcommand 'receive', 'Receive what is pushed into the repository', ReceiveCommand + 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