lib/glman/commands/base.rb in glman-0.0.5 vs lib/glman/commands/base.rb in glman-0.0.6
- old
+ new
@@ -18,24 +18,20 @@
message = params[1] || git_repo.last_commit_message || current_branch
repository_name = git_repo.repository_name
params = {assignee_id: user_id, title: message, source_branch: current_branch, target_branch: target_branch}
- push_branch_first(current_branch) if push?
+ push_branch_first(origin, current_branch) unless origin.nil?
projects_repo.create_merge_request(repository_name, params)
ap params.merge({user_name: user_name, repository_name: repository_name})
end
- def push=(push)
- @push = push
+ def push=(origin=nil)
+ @origin = origin || 'origin'
end
- def push?
- @push
- end
-
def show=(bool)
@show = bool
end
def show?
@@ -59,11 +55,11 @@
# Set user alias
def user_alias(params)
if clear?
configuration.clear_user_aliases
else
- configuration.add_user_alias(email: params[0], alias: params[1])
+ params.empty? ? show_aliases : configuration.add_user_alias(email: params[0], alias: params[1])
end
config
end
# Make Cache for user
@@ -97,30 +93,33 @@
def init?
@init
end
# Show help
- def help?
- puts 'help me :D'
+ def help!
+ puts 'Need help :D'
+ puts help_page
exit
end
- alias :h? :help?
+ alias :h! :help!
#Exec
def call(name=nil, *params)
+ intro
case name.to_s.strip
when 'config' then config(params)
when 'alias' then user_alias(params)
when 'cache' then cache
when 'mr' then mr(params)
when '' then puts '-'
else puts "what ?"
end
end
private
+ attr_reader :origin
- def push_branch_first(branch)
+ def push_branch_first(origin, branch)
p "push branch: #{branch} to origin: origin"
git_repo.push('origin', branch)
end
def show_all_mrs
@@ -143,9 +142,35 @@
@projects_repo ||= Repos::ProjectsRepo.new(configuration.load)
end
def git_repo
@git_repo ||= Repos::GitRepo.new
+ end
+
+ def help_page
+ %{
+ commands:
+
+ config # display current configuration
+ config <gitlab_url> <private_token> --init # init configuration
+
+ alias # display aliases
+ alias <user_email> <alias> # make alias for user email
+ alias --clear # clear all aliases
+
+ cache # build user cache for better performance RECOMMENDED
+ cache --clear # clear user cache
+
+ mr <user_email_or_alias> # create merge request for user for current branch to master with title as last commit message
+
+ mr <user_email_or_alias> <message> <target_branch> --push <origin> # full options for merge request (default origin is a origin :D)
+
+ Any questions pniemczyk@o2.pl or go to https://github.com/pniemczyk/glman
+ }
+ end
+
+ def intro
+ puts "Glman ver: #{VERSION}"
end
end
end
end
\ No newline at end of file