gitloggl 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +127 -0
- data/LICENSE.txt +20 -0
- data/README.md +11 -0
- data/Rakefile +6 -0
- data/bin/console +5 -0
- data/bin/gitloggl +11 -0
- data/bin/setup +8 -0
- data/exe/gitloggl +18 -0
- data/gitloggl.gemspec +46 -0
- data/lib/gitloggl/cli.rb +16 -0
- data/lib/gitloggl/command.rb +167 -0
- data/lib/gitloggl/commands/gitlab_cfg.rb +50 -0
- data/lib/gitloggl/commands/main.rb +20 -0
- data/lib/gitloggl/commands/sync.rb +133 -0
- data/lib/gitloggl/commands/toggl_cfg.rb +53 -0
- data/lib/gitloggl/connection.rb +39 -0
- data/lib/gitloggl/const.rb +8 -0
- data/lib/gitloggl/gitlab/cli.rb +86 -0
- data/lib/gitloggl/gitlab/issue.rb +25 -0
- data/lib/gitloggl/gitlab/stack/abstract.rb +50 -0
- data/lib/gitloggl/gitlab/stack/detect_project.rb +19 -0
- data/lib/gitloggl/gitlab/stack/filter.rb +15 -0
- data/lib/gitloggl/gitlab/stack/group_agg.rb +21 -0
- data/lib/gitloggl/gitlab/stack/load_notes.rb +31 -0
- data/lib/gitloggl/gitlab/stack/update_spent.rb +45 -0
- data/lib/gitloggl/templates/.gitkeep +1 -0
- data/lib/gitloggl/templates/toggle_conf/.gitkeep +1 -0
- data/lib/gitloggl/toggle/cli.rb +60 -0
- data/lib/gitloggl/version.rb +3 -0
- data/lib/gitloggl.rb +58 -0
- metadata +344 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 23b73d209666921562a008cbe2ab3a816bf18663cb810a77cd9a75fd7a61a847
|
4
|
+
data.tar.gz: 6f18a9d5bbebaf61d95fc3580d2f3c70f8b9b79d1032eb112855b179bdc08832
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a3733c4c115baef71cabad321d8d3856ddd49064070b26fd0ad9c27843dd1b005df92455dde25e2cf0cdf2b295882693647d3af2b51186c9f9921872b58d1e6
|
7
|
+
data.tar.gz: 7bc807d53c3fb07aba97c800a64bf20096798588a0bde524fc516e86754a810a5d49800b1ad8fb3bed9381a379ad0c1a41a32c928f199ec9007c6199d5b7507c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -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 a.shilov@finservice.pro. 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
data/Gemfile.lock
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gitloggl (0.1.0)
|
5
|
+
activesupport
|
6
|
+
chronic_duration
|
7
|
+
faraday
|
8
|
+
faraday_middleware
|
9
|
+
hooks
|
10
|
+
ibsciss-middleware
|
11
|
+
pastel
|
12
|
+
thor
|
13
|
+
tty-color
|
14
|
+
tty-command
|
15
|
+
tty-config
|
16
|
+
tty-progressbar
|
17
|
+
tty-prompt
|
18
|
+
tty-table
|
19
|
+
typhoeus
|
20
|
+
|
21
|
+
GEM
|
22
|
+
remote: https://rubygems.org/
|
23
|
+
specs:
|
24
|
+
activesupport (5.2.2)
|
25
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
+
i18n (>= 0.7, < 2)
|
27
|
+
minitest (~> 5.1)
|
28
|
+
tzinfo (~> 1.1)
|
29
|
+
chronic_duration (0.10.6)
|
30
|
+
numerizer (~> 0.1.1)
|
31
|
+
coderay (1.1.2)
|
32
|
+
concurrent-ruby (1.1.4)
|
33
|
+
diff-lcs (1.3)
|
34
|
+
equatable (0.5.0)
|
35
|
+
ethon (0.12.0)
|
36
|
+
ffi (>= 1.3.0)
|
37
|
+
faraday (0.15.4)
|
38
|
+
multipart-post (>= 1.2, < 3)
|
39
|
+
faraday_middleware (0.13.1)
|
40
|
+
faraday (>= 0.7.4, < 1.0)
|
41
|
+
ffi (1.10.0)
|
42
|
+
hooks (0.4.1)
|
43
|
+
uber (~> 0.0.14)
|
44
|
+
i18n (1.5.3)
|
45
|
+
concurrent-ruby (~> 1.0)
|
46
|
+
ibsciss-middleware (0.4.2)
|
47
|
+
method_source (0.9.2)
|
48
|
+
minitest (5.11.3)
|
49
|
+
multipart-post (2.0.0)
|
50
|
+
necromancer (0.4.0)
|
51
|
+
numerizer (0.1.1)
|
52
|
+
pastel (0.7.2)
|
53
|
+
equatable (~> 0.5.0)
|
54
|
+
tty-color (~> 0.4.0)
|
55
|
+
pry (0.12.2)
|
56
|
+
coderay (~> 1.1.0)
|
57
|
+
method_source (~> 0.9.0)
|
58
|
+
rake (10.5.0)
|
59
|
+
rspec (3.8.0)
|
60
|
+
rspec-core (~> 3.8.0)
|
61
|
+
rspec-expectations (~> 3.8.0)
|
62
|
+
rspec-mocks (~> 3.8.0)
|
63
|
+
rspec-core (3.8.0)
|
64
|
+
rspec-support (~> 3.8.0)
|
65
|
+
rspec-expectations (3.8.2)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.8.0)
|
68
|
+
rspec-mocks (3.8.0)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.8.0)
|
71
|
+
rspec-support (3.8.0)
|
72
|
+
strings (0.1.4)
|
73
|
+
strings-ansi (~> 0.1.0)
|
74
|
+
unicode-display_width (~> 1.4.0)
|
75
|
+
unicode_utils (~> 1.4.0)
|
76
|
+
strings-ansi (0.1.0)
|
77
|
+
thor (0.20.3)
|
78
|
+
thread_safe (0.3.6)
|
79
|
+
timers (4.3.0)
|
80
|
+
tty-color (0.4.3)
|
81
|
+
tty-command (0.8.2)
|
82
|
+
pastel (~> 0.7.0)
|
83
|
+
tty-config (0.3.1)
|
84
|
+
tty-cursor (0.6.0)
|
85
|
+
tty-progressbar (0.16.0)
|
86
|
+
strings-ansi (~> 0.1.0)
|
87
|
+
tty-cursor (~> 0.6.0)
|
88
|
+
tty-screen (~> 0.6.4)
|
89
|
+
unicode-display_width (~> 1.3)
|
90
|
+
tty-prompt (0.18.1)
|
91
|
+
necromancer (~> 0.4.0)
|
92
|
+
pastel (~> 0.7.0)
|
93
|
+
timers (~> 4.0)
|
94
|
+
tty-cursor (~> 0.6.0)
|
95
|
+
tty-reader (~> 0.5.0)
|
96
|
+
tty-reader (0.5.0)
|
97
|
+
tty-cursor (~> 0.6.0)
|
98
|
+
tty-screen (~> 0.6.4)
|
99
|
+
wisper (~> 2.0.0)
|
100
|
+
tty-screen (0.6.5)
|
101
|
+
tty-table (0.10.0)
|
102
|
+
equatable (~> 0.5.0)
|
103
|
+
necromancer (~> 0.4.0)
|
104
|
+
pastel (~> 0.7.2)
|
105
|
+
strings (~> 0.1.0)
|
106
|
+
tty-screen (~> 0.6.4)
|
107
|
+
typhoeus (1.3.1)
|
108
|
+
ethon (>= 0.9.0)
|
109
|
+
tzinfo (1.2.5)
|
110
|
+
thread_safe (~> 0.1)
|
111
|
+
uber (0.0.15)
|
112
|
+
unicode-display_width (1.4.1)
|
113
|
+
unicode_utils (1.4.0)
|
114
|
+
wisper (2.0.0)
|
115
|
+
|
116
|
+
PLATFORMS
|
117
|
+
ruby
|
118
|
+
|
119
|
+
DEPENDENCIES
|
120
|
+
bundler
|
121
|
+
gitloggl!
|
122
|
+
pry
|
123
|
+
rake
|
124
|
+
rspec
|
125
|
+
|
126
|
+
BUNDLED WITH
|
127
|
+
1.17.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Shilov Alexander
|
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
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/gitloggl
ADDED
data/bin/setup
ADDED
data/exe/gitloggl
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 'gitloggl/cli'
|
7
|
+
|
8
|
+
Signal.trap('INT') do
|
9
|
+
warn("\n#{caller.join("\n")}: interrupted")
|
10
|
+
exit(1)
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
Gitloggl::CLI.start
|
15
|
+
rescue Gitloggl::CLI::Error => err
|
16
|
+
puts "ERROR: #{err.message}"
|
17
|
+
exit 1
|
18
|
+
end
|
data/gitloggl.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "gitloggl/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gitloggl"
|
8
|
+
spec.license = "MIT"
|
9
|
+
spec.version = Gitloggl::VERSION
|
10
|
+
spec.authors = ['Shylau Aloaksandr']
|
11
|
+
spec.email = %w[alex.shilov.by@gmail.com]
|
12
|
+
|
13
|
+
spec.summary = ''
|
14
|
+
spec.description = ''
|
15
|
+
spec.homepage = 'https://github.com/shlima/gitloggl'
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = 'exe'
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = %w[lib]
|
25
|
+
|
26
|
+
spec.add_dependency 'tty-color'
|
27
|
+
spec.add_dependency 'tty-command'
|
28
|
+
spec.add_dependency 'tty-config'
|
29
|
+
spec.add_dependency 'tty-progressbar'
|
30
|
+
spec.add_dependency 'tty-prompt'
|
31
|
+
spec.add_dependency 'tty-table'
|
32
|
+
spec.add_dependency 'pastel'
|
33
|
+
spec.add_dependency 'thor'
|
34
|
+
spec.add_dependency 'activesupport'
|
35
|
+
spec.add_dependency 'typhoeus'
|
36
|
+
spec.add_dependency 'faraday'
|
37
|
+
spec.add_dependency 'faraday_middleware'
|
38
|
+
spec.add_dependency 'chronic_duration'
|
39
|
+
spec.add_dependency 'hooks'
|
40
|
+
spec.add_dependency 'ibsciss-middleware'
|
41
|
+
|
42
|
+
spec.add_development_dependency 'bundler'
|
43
|
+
spec.add_development_dependency 'rake'
|
44
|
+
spec.add_development_dependency 'rspec'
|
45
|
+
spec.add_development_dependency 'pry'
|
46
|
+
end
|
data/lib/gitloggl/cli.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module Gitloggl
|
6
|
+
class CLI < Thor
|
7
|
+
class_option :verbose, type: :boolean, default: false, desc: 'Run in verbose mode'
|
8
|
+
|
9
|
+
desc 'menu', 'launch program'
|
10
|
+
def menu
|
11
|
+
Gitloggl::Commands::Main.new(options).execute
|
12
|
+
rescue TTY::Reader::InputInterrupt
|
13
|
+
puts
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,167 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module Gitloggl
|
6
|
+
class Command
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
def_delegators :command, :run
|
10
|
+
|
11
|
+
attr_reader :options
|
12
|
+
|
13
|
+
# callable back action
|
14
|
+
attr_accessor :back
|
15
|
+
|
16
|
+
def initialize(options = {})
|
17
|
+
@options = options
|
18
|
+
yield(self) if block_given?
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [Boolean]
|
22
|
+
def back?
|
23
|
+
@back.respond_to?(:call)
|
24
|
+
end
|
25
|
+
|
26
|
+
def capture_back
|
27
|
+
-> { self.class.new.execute }
|
28
|
+
end
|
29
|
+
|
30
|
+
def menu_back(menu)
|
31
|
+
return unless back?
|
32
|
+
|
33
|
+
menu.choice 'Back', back
|
34
|
+
end
|
35
|
+
|
36
|
+
# @return [Boolean]
|
37
|
+
def verbose?
|
38
|
+
options['verbose']
|
39
|
+
end
|
40
|
+
|
41
|
+
# Execute this command
|
42
|
+
#
|
43
|
+
# @api public
|
44
|
+
def execute(*)
|
45
|
+
raise(
|
46
|
+
NotImplementedError,
|
47
|
+
"#{self.class}##{__method__} must be implemented"
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
# The external commands runner
|
52
|
+
#
|
53
|
+
# @see http://www.rubydoc.info/gems/tty-command
|
54
|
+
#
|
55
|
+
# @api public
|
56
|
+
def command(**options)
|
57
|
+
require 'tty-command'
|
58
|
+
TTY::Command.new(options)
|
59
|
+
end
|
60
|
+
|
61
|
+
# The cursor movement
|
62
|
+
#
|
63
|
+
# @see http://www.rubydoc.info/gems/tty-cursor
|
64
|
+
#
|
65
|
+
# @api public
|
66
|
+
def cursor
|
67
|
+
require 'tty-cursor'
|
68
|
+
TTY::Cursor
|
69
|
+
end
|
70
|
+
|
71
|
+
# Open a file or text in the user's preferred editor
|
72
|
+
#
|
73
|
+
# @see http://www.rubydoc.info/gems/tty-editor
|
74
|
+
#
|
75
|
+
# @api public
|
76
|
+
def editor
|
77
|
+
require 'tty-editor'
|
78
|
+
TTY::Editor
|
79
|
+
end
|
80
|
+
|
81
|
+
# File manipulation utility methods
|
82
|
+
#
|
83
|
+
# @see http://www.rubydoc.info/gems/tty-file
|
84
|
+
#
|
85
|
+
# @api public
|
86
|
+
def generator
|
87
|
+
require 'tty-file'
|
88
|
+
TTY::File
|
89
|
+
end
|
90
|
+
|
91
|
+
# Terminal output paging
|
92
|
+
#
|
93
|
+
# @see http://www.rubydoc.info/gems/tty-pager
|
94
|
+
#
|
95
|
+
# @api public
|
96
|
+
def pager(**options)
|
97
|
+
require 'tty-pager'
|
98
|
+
TTY::Pager.new(options)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Terminal platform and OS properties
|
102
|
+
#
|
103
|
+
# @see http://www.rubydoc.info/gems/tty-pager
|
104
|
+
#
|
105
|
+
# @api public
|
106
|
+
def platform
|
107
|
+
require 'tty-platform'
|
108
|
+
TTY::Platform.new
|
109
|
+
end
|
110
|
+
|
111
|
+
# The interactive prompt
|
112
|
+
#
|
113
|
+
# @see http://www.rubydoc.info/gems/tty-prompt
|
114
|
+
#
|
115
|
+
# @api public
|
116
|
+
def prompt(**options)
|
117
|
+
require 'tty-prompt'
|
118
|
+
TTY::Prompt.new(options)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Get terminal screen properties
|
122
|
+
#
|
123
|
+
# @see http://www.rubydoc.info/gems/tty-screen
|
124
|
+
#
|
125
|
+
# @api public
|
126
|
+
def screen
|
127
|
+
require 'tty-screen'
|
128
|
+
TTY::Screen
|
129
|
+
end
|
130
|
+
|
131
|
+
# The unix which utility
|
132
|
+
#
|
133
|
+
# @see http://www.rubydoc.info/gems/tty-which
|
134
|
+
#
|
135
|
+
# @api public
|
136
|
+
def which(*args)
|
137
|
+
require 'tty-which'
|
138
|
+
TTY::Which.which(*args)
|
139
|
+
end
|
140
|
+
|
141
|
+
# Check if executable exists
|
142
|
+
#
|
143
|
+
# @see http://www.rubydoc.info/gems/tty-which
|
144
|
+
#
|
145
|
+
# @api public
|
146
|
+
def exec_exist?(*args)
|
147
|
+
require 'tty-which'
|
148
|
+
TTY::Which.exist?(*args)
|
149
|
+
end
|
150
|
+
|
151
|
+
def pastel(opts = {})
|
152
|
+
Pastel.new(opts)
|
153
|
+
end
|
154
|
+
|
155
|
+
def config
|
156
|
+
@config ||= begin
|
157
|
+
require 'tty-config'
|
158
|
+
TTY::Config.new do |c|
|
159
|
+
c.filename = '.gitloggl'
|
160
|
+
c.extname = '.yml'
|
161
|
+
c.prepend_path(Dir.home)
|
162
|
+
c.read if c.exist?
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gitloggl
|
4
|
+
module Commands
|
5
|
+
class GitlabCfg < Gitloggl::Command
|
6
|
+
def execute(*)
|
7
|
+
render_config_table
|
8
|
+
|
9
|
+
prompt.select('') do |menu|
|
10
|
+
menu.choice 'Back', back if back?
|
11
|
+
menu.choice 'Add site', -> { add_site }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def add_site
|
18
|
+
domain = ask_domain
|
19
|
+
token = ask_token
|
20
|
+
|
21
|
+
return unless prompt.yes?("Change settings? Domain: #{pastel.green(domain)}, token: #{pastel.green(token)}")
|
22
|
+
|
23
|
+
config.set(Const::GITLAB_URL, value: domain)
|
24
|
+
config.set(Const::GITLAB_TOKEN, value: token)
|
25
|
+
|
26
|
+
config.write(force: true)
|
27
|
+
end
|
28
|
+
|
29
|
+
def ask_domain
|
30
|
+
prompt.ask('Enter gitlab domain:', default: 'https://gitlab.com') do |q|
|
31
|
+
q.required true
|
32
|
+
q.validate /\A.+\Z/
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def ask_token
|
37
|
+
prompt.ask('Enter access token') do |q|
|
38
|
+
q.required true
|
39
|
+
q.validate /\A.+\Z/
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def render_config_table
|
44
|
+
table = TTY::Table.new header: %w[Domain Token]
|
45
|
+
table << [config.fetch(Const::GITLAB_URL), config.fetch(Const::GITLAB_TOKEN)]
|
46
|
+
puts table.render :unicode, padding: 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gitloggl
|
4
|
+
module Commands
|
5
|
+
class Main < Gitloggl::Command
|
6
|
+
def execute(*)
|
7
|
+
action = prompt.select('') do |menu|
|
8
|
+
menu.choice 'SYNC', Sync
|
9
|
+
menu.choice 'gitlab.com config', GitlabCfg
|
10
|
+
menu.choice 'toggl.com config', TogglCfg
|
11
|
+
end
|
12
|
+
|
13
|
+
action.new(options) do |a|
|
14
|
+
a.back = capture_back
|
15
|
+
a.execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|