lib/alfred_git.rb in alfred_git-0.4.3 vs lib/alfred_git.rb in alfred_git-0.5.3
- old
+ new
@@ -39,25 +39,37 @@
case @arguments[0]
when nil, ''
lines_pretty_print Rainbow("I need a command to run, Master #{@name}.").red
abort
- when 'list_repo', 'list_repos'
+ when 'list_repo', 'list_repos', 'listrepo', 'listrepos'
lines_pretty_print "Here are your repos and their locations, Master #{@name}:"
single_space
list_repos_and_locations
single_space
abort
- when 'add_repo'
+ when 'add_repo', 'addrepo'
+ if second_argument_missing?
+ lines_pretty_print Rainbow("I need a repo name for the new repo, Master #{@name}.").red
+
+ abort
+ end
+
add_repo
abort
- when 'delete_repo'
+ when 'delete_repo', 'deleterepo', 'deletrepo'
+ if second_argument_missing?
+ lines_pretty_print Rainbow("I need a repo name to know which repo I'm deleting, Master #{@name}.").red
+
+ abort
+ end
+
delete_repo
abort
end
end
@@ -67,44 +79,40 @@
lines_pretty_print Rainbow("#{repo}").yellow + ": #{location}"
end
end
def add_repo
- config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
- config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
+ repo_name = @arguments[1]
- lines_pretty_print "What is the 'friendly' name you'd like to give your repository? This is the "\
- 'name you will type when sending me commands.'
-
- repo_name = STDIN.gets.strip!
-
single_space
- lines_pretty_print "Thank you, #{@gender}. Now, where is that repository? Please paste the full path."
+ lines_pretty_print "I can add the #{repo_name} repo straight away, #{@gender}. Where is that repository? "\
+ 'Please paste the full path.'
repo_path = STDIN.gets.strip!
single_space
+ config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
+ config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
+
config_yaml['repos'][repo_name] = repo_path
YAML.dump(config_yaml, config_file)
lines_pretty_print Rainbow("I've added that repository successfully, #{@gender}!").green
single_space
end
def delete_repo
- config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
- config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
+ repo_name = @arguments[1]
- lines_pretty_print "What repository would you like to delete from my list of repositories, #{@gender}?"
-
- repo_name = STDIN.gets.strip!
-
single_space
+ config_yaml = YAML.load_file("#{@app_directory}/lib/config.yaml")
+ config_file = File.open("#{@app_directory}/lib/config.yaml", 'w')
+
if config_yaml['repos'].keys.include?(repo_name)
config_yaml['repos'].delete(repo_name)
lines_pretty_print Rainbow("I've deleted that repository successfully, #{@gender}!").green
else
@@ -158,17 +166,17 @@
delete_arguments(1)
when 'branches', 'branch'
command = 'git rev-parse --abbrev-ref HEAD'
delete_arguments(1)
- when 'woa', 'wielder_of_anor'
+ when 'woa', 'wielder_of_anor', 'wielderofanor'
if second_argument_missing?
lines_pretty_print Rainbow("I need a commit message to pass to wielder_of_anor, Master #{@name}.").red
abort
end
- if @arguments[2] == '1'
+ if @arguments[2] && @arguments[2] == '1'
command = %Q[wielder_of_anor "#{@arguments[1]}" 1]
delete_arguments(3)
else
command = %Q[wielder_of_anor "#{@arguments[1]}"]
\ No newline at end of file