guac 0.0.1.pre.beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1096535c003d8bcae9b299a2486a74fe90d9fb93
4
+ data.tar.gz: 3d435a067356b557cc0ea7b93bb6cf4818f5890d
5
+ SHA512:
6
+ metadata.gz: 7ecf2a26f0616968725a2f7366ff95bfac415f08d510e8a648103b7bfd07d21fdfb9930adf7487e0e1835dbcb961c23b284f4309ca5d448333e7c0cdc0db4585
7
+ data.tar.gz: a6956bf8ca6e8ddd3cc350d452465ff00089f9b0922e59c6e03b520fa54027e94eb2ff19a2d9e44d0d2fb5ff2fdb25a9bbe7acea6ff62f8ae083b209898ff435
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at me@mattboldt.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in guac.gemspec
6
+ gemspec
7
+
8
+ gem 'tty'
9
+ gem 'pry'
10
+ gem 'colorize'
data/Gemfile.lock ADDED
@@ -0,0 +1,152 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ guac (0.0.1.pre.beta)
5
+ pastel (~> 0.7.2)
6
+ thor (~> 0.20.0)
7
+ tty-color (~> 0.4.2)
8
+ tty-command (~> 0.8.0)
9
+ tty-config (~> 0.2.0)
10
+ tty-cursor (~> 0.5.0)
11
+ tty-editor (~> 0.4.0)
12
+ tty-file (~> 0.6.0)
13
+ tty-font (~> 0.2.0)
14
+ tty-markdown (~> 0.4.0)
15
+ tty-pager (~> 0.11.0)
16
+ tty-platform (~> 0.1.0)
17
+ tty-progressbar (~> 0.15.0)
18
+ tty-prompt (~> 0.16.1)
19
+ tty-screen (~> 0.6.4)
20
+ tty-spinner (~> 0.8.0)
21
+ tty-table (~> 0.10.0)
22
+ tty-tree (~> 0.1.0)
23
+ tty-which (~> 0.3.0)
24
+
25
+ GEM
26
+ remote: https://rubygems.org/
27
+ specs:
28
+ coderay (1.1.2)
29
+ colorize (0.8.1)
30
+ diff-lcs (1.3)
31
+ equatable (0.5.0)
32
+ hitimes (1.3.0)
33
+ kramdown (1.16.2)
34
+ method_source (0.9.0)
35
+ necromancer (0.4.0)
36
+ pastel (0.7.2)
37
+ equatable (~> 0.5.0)
38
+ tty-color (~> 0.4.0)
39
+ pry (0.11.3)
40
+ coderay (~> 1.1.0)
41
+ method_source (~> 0.9.0)
42
+ rake (10.5.0)
43
+ rouge (3.1.1)
44
+ rspec (3.8.0)
45
+ rspec-core (~> 3.8.0)
46
+ rspec-expectations (~> 3.8.0)
47
+ rspec-mocks (~> 3.8.0)
48
+ rspec-core (3.8.0)
49
+ rspec-support (~> 3.8.0)
50
+ rspec-expectations (3.8.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.8.0)
53
+ rspec-mocks (3.8.0)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.8.0)
56
+ rspec-support (3.8.0)
57
+ strings (0.1.1)
58
+ unicode-display_width (~> 1.3.0)
59
+ unicode_utils (~> 1.4.0)
60
+ thor (0.20.0)
61
+ timers (4.1.2)
62
+ hitimes
63
+ tty (0.8.1)
64
+ bundler (~> 1.16, < 2.0)
65
+ equatable (~> 0.5.0)
66
+ pastel (~> 0.7.2)
67
+ thor (~> 0.20.0)
68
+ tty-color (~> 0.4.2)
69
+ tty-command (~> 0.8.0)
70
+ tty-config (~> 0.2.0)
71
+ tty-cursor (~> 0.5.0)
72
+ tty-editor (~> 0.4.0)
73
+ tty-file (~> 0.6.0)
74
+ tty-font (~> 0.2.0)
75
+ tty-markdown (~> 0.4.0)
76
+ tty-pager (~> 0.11.0)
77
+ tty-platform (~> 0.1.0)
78
+ tty-progressbar (~> 0.15.0)
79
+ tty-prompt (~> 0.16.1)
80
+ tty-screen (~> 0.6.4)
81
+ tty-spinner (~> 0.8.0)
82
+ tty-table (~> 0.10.0)
83
+ tty-tree (~> 0.1.0)
84
+ tty-which (~> 0.3.0)
85
+ tty-color (0.4.3)
86
+ tty-command (0.8.1)
87
+ pastel (~> 0.7.0)
88
+ tty-config (0.2.0)
89
+ tty-cursor (0.5.0)
90
+ tty-editor (0.4.0)
91
+ tty-prompt (~> 0.16.0)
92
+ tty-which (~> 0.3.0)
93
+ tty-file (0.6.0)
94
+ diff-lcs (~> 1.3.0)
95
+ pastel (~> 0.7.2)
96
+ tty-prompt (~> 0.16.1)
97
+ tty-font (0.2.0)
98
+ tty-markdown (0.4.0)
99
+ kramdown (~> 1.16.2)
100
+ pastel (~> 0.7.2)
101
+ rouge (~> 3.1.0)
102
+ strings (~> 0.1.0)
103
+ tty-color (~> 0.4.2)
104
+ tty-screen (~> 0.6.4)
105
+ tty-pager (0.11.0)
106
+ strings (~> 0.1.0)
107
+ tty-screen (~> 0.6.4)
108
+ tty-which (~> 0.3.0)
109
+ tty-platform (0.1.0)
110
+ tty-progressbar (0.15.1)
111
+ tty-cursor (~> 0.5.0)
112
+ tty-screen (~> 0.6.4)
113
+ unicode-display_width (~> 1.3)
114
+ tty-prompt (0.16.1)
115
+ necromancer (~> 0.4.0)
116
+ pastel (~> 0.7.0)
117
+ timers (~> 4.0)
118
+ tty-cursor (~> 0.5.0)
119
+ tty-reader (~> 0.3.0)
120
+ tty-reader (0.3.0)
121
+ tty-cursor (~> 0.5.0)
122
+ tty-screen (~> 0.6.4)
123
+ wisper (~> 2.0.0)
124
+ tty-screen (0.6.5)
125
+ tty-spinner (0.8.0)
126
+ tty-cursor (>= 0.5.0)
127
+ tty-table (0.10.0)
128
+ equatable (~> 0.5.0)
129
+ necromancer (~> 0.4.0)
130
+ pastel (~> 0.7.2)
131
+ strings (~> 0.1.0)
132
+ tty-screen (~> 0.6.4)
133
+ tty-tree (0.1.0)
134
+ tty-which (0.3.0)
135
+ unicode-display_width (1.3.3)
136
+ unicode_utils (1.4.0)
137
+ wisper (2.0.0)
138
+
139
+ PLATFORMS
140
+ ruby
141
+
142
+ DEPENDENCIES
143
+ bundler (~> 1.16)
144
+ colorize
145
+ guac!
146
+ pry
147
+ rake (~> 10.0)
148
+ rspec (~> 3.0)
149
+ tty
150
+
151
+ BUNDLED WITH
152
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Matt Boldt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Guac
2
+
3
+ Guac is a command line program to manage multiple local git repos with one command. Guac stands for `git update cli`, but it's also just a very easy to type command. Furthermore, it's shorthand for Guacamole, e.g.: "Holy Guacamole, this gem makes updating all my repos very fast and easy".
4
+
5
+ Guac is written in Ruby, so you'll need to have that installed on your machine, but the functionality itself is language agnostic.
6
+
7
+ ## Installation
8
+
9
+ $ gem install guac
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ # Run setup
15
+ guac config
16
+
17
+ # Show all statuses
18
+ guac status
19
+
20
+ # Update all on master
21
+ guac up master
22
+ ```
23
+
24
+ ## Development
25
+
26
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
+
28
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mattboldt/guac. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
33
+
34
+ ## Code of Conduct
35
+
36
+ Everyone interacting in the Guac project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mattboldt/guac/blob/master/CODE_OF_CONDUCT.md).
37
+
38
+ ## Copyright
39
+
40
+ Copyright (c) 2018 Matt Boldt. See [MIT License](LICENSE.txt) for further details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "guac"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/reset ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+
3
+ cd ../sample_repos/ruby-progressbar
4
+ git reset --hard 141e71dfbbe76a98adf73746929f38743e62fd53
5
+ cd ../tty-progressbar
6
+ git reset --hard 223bfcda8e3c8826c4c25e119782dee42732719b
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/guac ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ lib_path = File.expand_path('../lib', __dir__)
5
+ $:.unshift(lib_path) if !$:.include?(lib_path)
6
+ require 'guac/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ Guac::CLI.start
15
+ rescue Guac::CLI::Error => err
16
+ puts "ERROR: #{err.message}"
17
+ exit 1
18
+ end
data/guac.gemspec ADDED
@@ -0,0 +1,59 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "guac/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "guac"
8
+ spec.license = "MIT"
9
+ spec.version = Guac::VERSION
10
+ spec.authors = ['Matt Boldt']
11
+ spec.email = ['me@mattboldt.com']
12
+
13
+ spec.summary = 'Git your gits'
14
+ spec.description = 'Git your gits git'
15
+ spec.homepage = 'https://github.com/mattboldt/guac'
16
+ spec.license = 'MIT'
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ if spec.respond_to?(:metadata)
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
+ else
23
+ raise "RubyGems 2.0 or newer is required to protect against " \
24
+ "public gem pushes."
25
+ end
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_dependency "tty-color", "~> 0.4.2"
37
+ spec.add_dependency "tty-command", "~> 0.8.0"
38
+ spec.add_dependency "tty-config", "~> 0.2.0"
39
+ spec.add_dependency "tty-cursor", "~> 0.5.0"
40
+ spec.add_dependency "tty-editor", "~> 0.4.0"
41
+ spec.add_dependency "tty-file", "~> 0.6.0"
42
+ spec.add_dependency "tty-font", "~> 0.2.0"
43
+ spec.add_dependency "tty-markdown", "~> 0.4.0"
44
+ spec.add_dependency "tty-pager", "~> 0.11.0"
45
+ spec.add_dependency "tty-platform", "~> 0.1.0"
46
+ spec.add_dependency "tty-progressbar", "~> 0.15.0"
47
+ spec.add_dependency "tty-prompt", "~> 0.16.1"
48
+ spec.add_dependency "tty-screen", "~> 0.6.4"
49
+ spec.add_dependency "tty-spinner", "~> 0.8.0"
50
+ spec.add_dependency "tty-table", "~> 0.10.0"
51
+ spec.add_dependency "tty-tree", "~> 0.1.0"
52
+ spec.add_dependency "tty-which", "~> 0.3.0"
53
+ spec.add_dependency "pastel", "~> 0.7.2"
54
+ spec.add_dependency "thor", "~> 0.20.0"
55
+
56
+ spec.add_development_dependency "bundler", "~> 1.16"
57
+ spec.add_development_dependency "rake", "~> 10.0"
58
+ spec.add_development_dependency "rspec", "~> 3.0"
59
+ end
data/lib/guac/cli.rb ADDED
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+ # require 'pry'
5
+
6
+ module Guac
7
+ # Handle the application command line parsing
8
+ # and the dispatch to various command objects
9
+ #
10
+ # @api public
11
+ class CLI < Thor
12
+ # Error raised by this runner
13
+ Error = Class.new(StandardError)
14
+
15
+ desc 'version', 'guac version'
16
+ def version
17
+ require_relative 'version'
18
+ puts "v#{Guac::VERSION}"
19
+ end
20
+ map %w(--version -v) => :version
21
+
22
+ desc 'config', 'Configures local repos'
23
+ method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
24
+ def config(*)
25
+ if options[:help]
26
+ invoke :help, ['config']
27
+ else
28
+ require_relative 'commands/config'
29
+ Guac::Commands::Config.new(options).execute
30
+ end
31
+ end
32
+
33
+ desc 'status', 'Show the status of all git repos'
34
+ method_option :help, aliases: '-h', type: :boolean
35
+ def status(*)
36
+ if options[:help]
37
+ invoke :help, ['status']
38
+ else
39
+ require_relative 'commands/status'
40
+ Guac::Commands::Status.new(options).execute
41
+ end
42
+ end
43
+
44
+ desc 'up', 'Pull latest for all repos'
45
+ method_option :help, aliases: '-h', type: :boolean, desc: 'Display usage information'
46
+ method_option :branch, aliases: '-b', type: :string, desc: 'Checkout branch and pull updates'
47
+ def up(*)
48
+ if options[:help]
49
+ invoke :help, ['up']
50
+ else
51
+ require_relative 'commands/up'
52
+ Guac::Commands::Up.new(options).execute
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'colorize'
4
+
5
+ class Colors
6
+ class << self
7
+ def paint(ary)
8
+ color =
9
+ if contains?(ary, 'Updating') || contains?(ary, 'Changes not staged for commit')
10
+ :yellow
11
+ elsif contains?(ary, 'Failed') || contains?(ary, 'error:')
12
+ :red
13
+ else
14
+ :green
15
+ end
16
+
17
+ [color, ary.map { |r| r.colorize(color) }]
18
+ end
19
+
20
+ def contains?(ary, string)
21
+ ary.compact.any? { |r| r.include?(string) }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+
5
+ module Guac
6
+ class Command
7
+ extend Forwardable
8
+
9
+ def_delegators :command, :run
10
+
11
+ # Execute this command
12
+ #
13
+ # @api public
14
+ def execute(*)
15
+ raise(
16
+ NotImplementedError,
17
+ "#{self.class}##{__method__} must be implemented"
18
+ )
19
+ end
20
+
21
+ # The external commands runner
22
+ #
23
+ # @see http://www.rubydoc.info/gems/tty-command
24
+ #
25
+ # @api public
26
+ def command(**options)
27
+ require 'tty-command'
28
+ TTY::Command.new(options)
29
+ end
30
+
31
+ # The cursor movement
32
+ #
33
+ # @see http://www.rubydoc.info/gems/tty-cursor
34
+ #
35
+ # @api public
36
+ def cursor
37
+ require 'tty-cursor'
38
+ TTY::Cursor
39
+ end
40
+
41
+ # Open a file or text in the user's preferred editor
42
+ #
43
+ # @see http://www.rubydoc.info/gems/tty-editor
44
+ #
45
+ # @api public
46
+ def editor
47
+ require 'tty-editor'
48
+ TTY::Editor
49
+ end
50
+
51
+ # File manipulation utility methods
52
+ #
53
+ # @see http://www.rubydoc.info/gems/tty-file
54
+ #
55
+ # @api public
56
+ def generator
57
+ require 'tty-file'
58
+ TTY::File
59
+ end
60
+
61
+ # Terminal output paging
62
+ #
63
+ # @see http://www.rubydoc.info/gems/tty-pager
64
+ #
65
+ # @api public
66
+ def pager(**options)
67
+ require 'tty-pager'
68
+ TTY::Pager.new(options)
69
+ end
70
+
71
+ # Terminal platform and OS properties
72
+ #
73
+ # @see http://www.rubydoc.info/gems/tty-pager
74
+ #
75
+ # @api public
76
+ def platform
77
+ require 'tty-platform'
78
+ TTY::Platform.new
79
+ end
80
+
81
+ # The interactive prompt
82
+ #
83
+ # @see http://www.rubydoc.info/gems/tty-prompt
84
+ #
85
+ # @api public
86
+ def prompt(**options)
87
+ require 'tty-prompt'
88
+ TTY::Prompt.new(options)
89
+ end
90
+
91
+ # Get terminal screen properties
92
+ #
93
+ # @see http://www.rubydoc.info/gems/tty-screen
94
+ #
95
+ # @api public
96
+ def screen
97
+ require 'tty-screen'
98
+ TTY::Screen
99
+ end
100
+
101
+ # The unix which utility
102
+ #
103
+ # @see http://www.rubydoc.info/gems/tty-which
104
+ #
105
+ # @api public
106
+ def which(*args)
107
+ require 'tty-which'
108
+ TTY::Which.which(*args)
109
+ end
110
+
111
+ # Check if executable exists
112
+ #
113
+ # @see http://www.rubydoc.info/gems/tty-which
114
+ #
115
+ # @api public
116
+ def exec_exist?(*args)
117
+ require 'tty-which'
118
+ TTY::Which.exist?(*args)
119
+ end
120
+ end
121
+ end
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+ require_relative '../config'
5
+ require 'yaml'
6
+ require 'colorize'
7
+ require 'pry'
8
+
9
+ module Guac
10
+ module Commands
11
+ class Config < Guac::Command
12
+
13
+ def initialize(options)
14
+ @options = options
15
+ @config = Guac::Config.load(raise_error: false)
16
+ @defaults = Guac::Config.defaults
17
+ end
18
+
19
+ def execute(_input: $stdin, output: $stdout)
20
+ body = @defaults
21
+ body.merge!(@config) unless @config.nil?
22
+
23
+ output.puts "============= \n\n\n"
24
+ prompt_repos(body, output)
25
+ output.puts "\n"
26
+ prompt_branch_aliases(body, output)
27
+ prompt_pull_strategy(body)
28
+ prompt_default_branch(body)
29
+ output.puts "\n"
30
+
31
+ save_config(body)
32
+ output.puts 'Config saved in ~/.guacrc'.colorize(:green)
33
+ end
34
+
35
+ private
36
+
37
+ def prompt_repos(body, output)
38
+ result = prompt.ask('Git Repos (separated by spaces):'.bold.colorize(:blue), required: true)
39
+
40
+ dirs = result.split(/ \s*/)
41
+ body[:repos] = dirs.map do |r|
42
+ {
43
+ dir: r,
44
+ name: r.split('/').last,
45
+ }
46
+ end
47
+ end
48
+
49
+ def prompt_branch_aliases(body, output)
50
+ output.puts 'Git branch aliases:'.bold.colorize(:blue)
51
+ output.puts %{
52
+ 2 of your repos may use 'master', while the 3rd uses 'master_v2'.
53
+ Use an alias to keep all 3 in sync. #{'Input format: `branch_name:branch_name_alias`'.colorize(:yellow)}
54
+ }
55
+
56
+ result = prompt.yes?('Would you like to configure aliases?')
57
+ return unless result
58
+
59
+ body[:repos].each do |repo|
60
+ result = prompt.ask("Alias for `#{repo[:name].colorize(:blue)}`:")
61
+ next unless valid_result?(result)
62
+
63
+ branch_pairs = result.split(/ \s*/)
64
+ repo[:branch_aliases] = {}.tap do |obj|
65
+ branch_pairs.each do |pair|
66
+ branches = pair.split(':')
67
+ obj[branches[0]] = branches[1]
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ def prompt_pull_strategy(body)
74
+ default = "(default: `#{@defaults[:pull_strategy]}`)".colorize(:blue)
75
+ result = prompt.ask("Pull strategy #{default}:")
76
+
77
+ body[:pull_strategy] = result if valid_result?(result)
78
+ end
79
+
80
+ def prompt_default_branch(body)
81
+ default = "(default: `#{@defaults[:default_branch]}`)".colorize(:blue)
82
+ result = prompt.ask("Default branch #{default}:")
83
+
84
+ body[:default_branch] = result if valid_result?(result)
85
+ end
86
+
87
+ def valid_result?(result)
88
+ result && !result.strip.empty?
89
+ end
90
+
91
+ def save_config(body)
92
+ file = File.new(Guac::Config::CONFIG_FILE, 'w')
93
+ file.puts(body.to_yaml)
94
+ file.close
95
+ end
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+ require_relative '../config'
5
+ require_relative '../repo'
6
+ require_relative '../colors'
7
+
8
+ module Guac
9
+ module Commands
10
+ class Status < Guac::Command
11
+ def initialize(options)
12
+ @options = options
13
+ @config = Guac::Config.load
14
+ @repos = @config[:repos].map { |r| Guac::Repo.new(@config, r) }
15
+ end
16
+
17
+ def execute(input: $stdin, output: $stdout)
18
+ @repos.each do |repo|
19
+ output.puts repo.name.bold.colorize(:blue)
20
+
21
+ response = [repo.status]
22
+
23
+ color, response = Colors.paint(response)
24
+ output.puts response.join("\n")
25
+ break if color == :red
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../command'
4
+ require_relative '../config'
5
+ require_relative '../repo'
6
+ require_relative '../colors'
7
+ require_relative '../sys_command'
8
+ require 'pry'
9
+
10
+ module Guac
11
+ module Commands
12
+ class Up < Guac::Command
13
+ def initialize(options)
14
+ @options = options
15
+ @config = Guac::Config.load
16
+ @repos = @config[:repos].map do |repo|
17
+ Guac::Repo.new(@config, repo, ARGV[1])
18
+ end
19
+ end
20
+
21
+ def execute(input: $stdin, output: $stdout)
22
+ @repos.each do |repo|
23
+ output.puts "Updating #{repo.name.bold} on branch #{repo.branch.underline}".colorize(:blue)
24
+ response = []
25
+
26
+ begin
27
+ repo.checkout
28
+ response << repo.pull
29
+ rescue Guac::SysCommandError => e
30
+ output.puts e.message.colorize(:red)
31
+ break
32
+ end
33
+
34
+ response.compact!
35
+ color, response = Colors.paint(response)
36
+ output.puts response.join("\n")
37
+ break if color == :red
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,24 @@
1
+ require 'yaml'
2
+ require 'colorize'
3
+
4
+ module Guac
5
+ class Config
6
+ CONFIG_FILE = File.join(ENV['HOME'], '.guacrc').freeze
7
+ DEFAULTS_FILE = File.join(File.dirname(__FILE__), 'templates/config/guacrc.yaml').freeze
8
+
9
+ def self.load(raise_error: true)
10
+ @config ||= YAML.load(File.read(CONFIG_FILE)) if File.exist?(CONFIG_FILE)
11
+
12
+ if @config.nil? && raise_error
13
+ puts 'ERROR: Please run config'.colorize(:red)
14
+ raise
15
+ end
16
+
17
+ @config
18
+ end
19
+
20
+ def self.defaults
21
+ @defaults ||= YAML.load(File.read(DEFAULTS_FILE)) if File.exist?(DEFAULTS_FILE)
22
+ end
23
+ end
24
+ end
data/lib/guac/repo.rb ADDED
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'sys_command'
4
+
5
+ module Guac
6
+ class Repo
7
+ attr_reader :name, :dir
8
+
9
+ def initialize(config, repo, branch = nil)
10
+ @config = config
11
+ @repo = repo
12
+ @name = repo[:name]
13
+ @dir = repo[:dir]
14
+ @branch = branch || config[:default_branch]
15
+ end
16
+
17
+ def branch
18
+ aliases = @repo[:branch_aliases]
19
+ if aliases
20
+ aliases[@branch] || @branch
21
+ else
22
+ @branch
23
+ end
24
+ end
25
+
26
+ def status
27
+ SysCommand.run(@dir, %w(git status))
28
+ end
29
+
30
+ def checkout
31
+ SysCommand.run(@dir, %W(git checkout #{branch}))
32
+ end
33
+
34
+ def pull
35
+ pull_cmd =
36
+ @config[:pull_strategy] ? @config[:pull_strategy] : @defaults[:pull_strategy]
37
+ pull_cmd = pull_cmd.split(/ \s*/)
38
+
39
+ SysCommand.run(@dir, pull_cmd)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ module Guac
6
+ class SysCommand
7
+ class << self
8
+ def run(dir, commands = [])
9
+ stdin, stdout, stderr, wait_thr = Open3.popen3(*commands, chdir: dir)
10
+ output = stdout.gets(nil)
11
+ error = stderr.gets(nil)
12
+ exit_status = wait_thr.value
13
+
14
+ stdout.close
15
+ stderr.close
16
+
17
+ if output.nil? && error
18
+ raise SysCommandError, error
19
+ end
20
+
21
+ output
22
+ end
23
+ end
24
+ end
25
+
26
+ class SysCommandError < StandardError
27
+ end
28
+ end
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1,4 @@
1
+ ---
2
+ :repos:
3
+ :pull_strategy: git pull --rebase --prune
4
+ :default_branch: master
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1,3 @@
1
+ module Guac
2
+ VERSION = "0.0.1-beta"
3
+ end
data/lib/guac.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "guac/version"
2
+
3
+ module Guac
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,385 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guac
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.beta
5
+ platform: ruby
6
+ authors:
7
+ - Matt Boldt
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tty-color
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.4.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.4.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: tty-command
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: tty-config
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.2.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: tty-cursor
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.5.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: tty-editor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.4.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.4.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: tty-file
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.6.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.6.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: tty-font
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.2.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.2.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: tty-markdown
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.4.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.4.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: tty-pager
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.11.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.11.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: tty-platform
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.1.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.1.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: tty-progressbar
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.15.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.15.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: tty-prompt
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.16.1
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.16.1
181
+ - !ruby/object:Gem::Dependency
182
+ name: tty-screen
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 0.6.4
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 0.6.4
195
+ - !ruby/object:Gem::Dependency
196
+ name: tty-spinner
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 0.8.0
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 0.8.0
209
+ - !ruby/object:Gem::Dependency
210
+ name: tty-table
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: 0.10.0
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: 0.10.0
223
+ - !ruby/object:Gem::Dependency
224
+ name: tty-tree
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: 0.1.0
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: 0.1.0
237
+ - !ruby/object:Gem::Dependency
238
+ name: tty-which
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: 0.3.0
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: 0.3.0
251
+ - !ruby/object:Gem::Dependency
252
+ name: pastel
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: 0.7.2
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: 0.7.2
265
+ - !ruby/object:Gem::Dependency
266
+ name: thor
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - "~>"
270
+ - !ruby/object:Gem::Version
271
+ version: 0.20.0
272
+ type: :runtime
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - "~>"
277
+ - !ruby/object:Gem::Version
278
+ version: 0.20.0
279
+ - !ruby/object:Gem::Dependency
280
+ name: bundler
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - "~>"
284
+ - !ruby/object:Gem::Version
285
+ version: '1.16'
286
+ type: :development
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - "~>"
291
+ - !ruby/object:Gem::Version
292
+ version: '1.16'
293
+ - !ruby/object:Gem::Dependency
294
+ name: rake
295
+ requirement: !ruby/object:Gem::Requirement
296
+ requirements:
297
+ - - "~>"
298
+ - !ruby/object:Gem::Version
299
+ version: '10.0'
300
+ type: :development
301
+ prerelease: false
302
+ version_requirements: !ruby/object:Gem::Requirement
303
+ requirements:
304
+ - - "~>"
305
+ - !ruby/object:Gem::Version
306
+ version: '10.0'
307
+ - !ruby/object:Gem::Dependency
308
+ name: rspec
309
+ requirement: !ruby/object:Gem::Requirement
310
+ requirements:
311
+ - - "~>"
312
+ - !ruby/object:Gem::Version
313
+ version: '3.0'
314
+ type: :development
315
+ prerelease: false
316
+ version_requirements: !ruby/object:Gem::Requirement
317
+ requirements:
318
+ - - "~>"
319
+ - !ruby/object:Gem::Version
320
+ version: '3.0'
321
+ description: Git your gits git
322
+ email:
323
+ - me@mattboldt.com
324
+ executables:
325
+ - guac
326
+ extensions: []
327
+ extra_rdoc_files: []
328
+ files:
329
+ - ".gitignore"
330
+ - ".rspec"
331
+ - ".travis.yml"
332
+ - CODE_OF_CONDUCT.md
333
+ - Gemfile
334
+ - Gemfile.lock
335
+ - LICENSE.txt
336
+ - README.md
337
+ - Rakefile
338
+ - bin/console
339
+ - bin/reset
340
+ - bin/setup
341
+ - exe/guac
342
+ - guac.gemspec
343
+ - lib/guac.rb
344
+ - lib/guac/cli.rb
345
+ - lib/guac/colors.rb
346
+ - lib/guac/command.rb
347
+ - lib/guac/commands/.gitkeep
348
+ - lib/guac/commands/config.rb
349
+ - lib/guac/commands/status.rb
350
+ - lib/guac/commands/up.rb
351
+ - lib/guac/config.rb
352
+ - lib/guac/repo.rb
353
+ - lib/guac/sys_command.rb
354
+ - lib/guac/templates/.gitkeep
355
+ - lib/guac/templates/config/.gitkeep
356
+ - lib/guac/templates/config/guacrc.yaml
357
+ - lib/guac/templates/status/.gitkeep
358
+ - lib/guac/templates/up/.gitkeep
359
+ - lib/guac/version.rb
360
+ homepage: https://github.com/mattboldt/guac
361
+ licenses:
362
+ - MIT
363
+ metadata:
364
+ allowed_push_host: https://rubygems.org
365
+ post_install_message:
366
+ rdoc_options: []
367
+ require_paths:
368
+ - lib
369
+ required_ruby_version: !ruby/object:Gem::Requirement
370
+ requirements:
371
+ - - ">="
372
+ - !ruby/object:Gem::Version
373
+ version: '0'
374
+ required_rubygems_version: !ruby/object:Gem::Requirement
375
+ requirements:
376
+ - - ">"
377
+ - !ruby/object:Gem::Version
378
+ version: 1.3.1
379
+ requirements: []
380
+ rubyforge_project:
381
+ rubygems_version: 2.6.14
382
+ signing_key:
383
+ specification_version: 4
384
+ summary: Git your gits
385
+ test_files: []