Class: MGit::AddCommand
Instance Method Summary
collapse
Methods inherited from Command
create, #help, instance_each, list, register_alias, register_command
Instance Method Details
#description ⇒ Object
19
20
21
|
# File 'lib/mgit/commands/add.rb', line 19
def description
'add a repository to mgit'
end
|
#execute(args) ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/mgit/commands/add.rb', line 3
def execute(args)
raise TooFewArgumentsError.new(self) if args.size == 0
raise TooManyArgumentsError.new(self) if args.size > 2
path = File.expand_path(args[0])
raise CommandUsageError.new('First argument must be a path to a git repository.', self) unless is_git_dir?(path)
name = (args.size == 2) ? args[1] : (ask('Name of the repository? ') { |q| q.default = File.basename(path) })
Repository.add(name, path)
end
|
#usage ⇒ Object
15
16
17
|
# File 'lib/mgit/commands/add.rb', line 15
def usage
'add <path_to_git_repository> [name]'
end
|