Class: Git::Copilot::CLI
- Inherits:
-
Thor
- Object
- Thor
- Git::Copilot::CLI
- Includes:
- Configuration
- Defined in:
- lib/git/copilot/cli.rb,
lib/git/copilot/cli/user.rb
Defined Under Namespace
Classes: User
Instance Method Summary collapse
Instance Method Details
#init ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/git/copilot/cli.rb', line 12 def init if File.exist?(config_file_path) && ![:force] return say_status "ERROR", "Configuration file already exists", :red end say "Writing configuration file to #{config_file_path}" File.write(config_file_path, empty_configuration) if yes?("Set up a global git alias? (This will allow you to run `git copilot`)") system("git config --global alias.copilot '\!git-copilot'") end solo end |
#pair(*usernames) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/git/copilot/cli.rb', line 37 def pair(*usernames) = usernames.map do |username| users.fetch(username) do say_status "WARNING", "Unknown user #{username}", :yellow next end end.compact if .empty? return say_status "ERROR", "No users to pair with. " \ "Did you mean to run git-copilot solo?", :red end self.current_pairs = commit_config write_template set_git_commit_template status end |
#solo ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/git/copilot/cli.rb', line 28 def solo clear_pairs commit_config write_template set_git_commit_template status end |
#status ⇒ Object
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/git/copilot/cli.rb', line 59 def status if current_pairs.empty? say "Now working solo", :green else say "Now working with #{pluralize_pairs(current_pairs.length)}:" current_pairs.each do || say format("%{name} <%{email}>", name: .name, email: .email), :green end end end |