github_cli 0.1.0 → 0.1.1
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.
- data/Gemfile.lock +1 -1
- data/features/search.feature +7 -0
- data/features/settings.feature +0 -1
- data/lib/github_cli/{blob.rb → apis/blob.rb} +1 -1
- data/lib/github_cli/apis/tag.rb +18 -0
- data/lib/github_cli/apis.rb +18 -0
- data/lib/github_cli/cli.rb +14 -15
- data/lib/github_cli/{blobs.rb → commands/blobs.rb} +1 -3
- data/lib/github_cli/{issues.rb → commands/issues.rb} +1 -3
- data/lib/github_cli/{labels.rb → commands/labels.rb} +2 -4
- data/lib/github_cli/{repositories.rb → commands/repositories.rb} +1 -3
- data/lib/github_cli/commands/tags.rb +25 -0
- data/lib/github_cli/{trees.rb → commands/trees.rb} +1 -3
- data/lib/github_cli/commands.rb +12 -0
- data/lib/github_cli/config.rb +19 -2
- data/lib/github_cli/dsl.rb +21 -0
- data/lib/github_cli/terminal.rb +31 -5
- data/lib/github_cli/ui.rb +4 -0
- data/lib/github_cli/version.rb +1 -1
- data/lib/github_cli.rb +14 -15
- data/spec/github_cli/command_spec.rb +1 -1
- data/spec/github_cli/config_spec.rb +3 -1
- data/spec/spec_helper.rb +5 -1
- metadata +25 -20
- /data/lib/github_cli/{repository.rb → apis/repository.rb} +0 -0
- /data/lib/github_cli/{tree.rb → apis/tree.rb} +0 -0
data/Gemfile.lock
CHANGED
data/features/search.feature
CHANGED
data/features/settings.feature
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Tag < API
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
def get(user, repo, sha, params)
|
9
|
+
github_api.repos.get_tag user, repo, params
|
10
|
+
end
|
11
|
+
|
12
|
+
def create(user, repo, params)
|
13
|
+
github_api.repos.create_tag user, repo, params
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end # Tag
|
18
|
+
end # GithubCLI
|
@@ -0,0 +1,18 @@
|
|
1
|
+
if defined?(require_relative)
|
2
|
+
def require_api(path)
|
3
|
+
require_relative "apis/#{path}"
|
4
|
+
end
|
5
|
+
else
|
6
|
+
def require_api(path)
|
7
|
+
require "github_cli/apis/#{path}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
%w[
|
12
|
+
blob
|
13
|
+
repository
|
14
|
+
tag
|
15
|
+
tree
|
16
|
+
].each do |api|
|
17
|
+
require_api api
|
18
|
+
end
|
data/lib/github_cli/cli.rb
CHANGED
@@ -6,14 +6,10 @@ module GithubCLI
|
|
6
6
|
|
7
7
|
def initialize(*args)
|
8
8
|
super
|
9
|
-
say <<-TEXT
|
10
|
-
|
11
|
-
Github CLI client
|
12
|
-
|
13
|
-
TEXT
|
14
9
|
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
15
10
|
GithubCLI.ui = UI.new(the_shell)
|
16
11
|
GithubCLi.ui.debug! if options["verbose"]
|
12
|
+
Terminal.print_program_name
|
17
13
|
end
|
18
14
|
|
19
15
|
map "repository" => :repo,
|
@@ -66,20 +62,23 @@ Github CLI client
|
|
66
62
|
Terminal.print_commands pattern
|
67
63
|
end
|
68
64
|
|
69
|
-
desc "blob <command>", "
|
70
|
-
subcommand "blob", GithubCLI::Blobs
|
65
|
+
desc "blob <command>", "Leverage Blobs API"
|
66
|
+
subcommand "blob", GithubCLI::Commands::Blobs
|
67
|
+
|
68
|
+
desc "repo <command>", "Leverage Repositories API"
|
69
|
+
subcommand "repo", GithubCLI::Commands::Repositories
|
71
70
|
|
72
|
-
desc "
|
73
|
-
subcommand "
|
71
|
+
desc "issue <command>", "Leverage Issues API"
|
72
|
+
subcommand "issue", GithubCLI::Commands::Issues
|
74
73
|
|
75
|
-
desc "
|
76
|
-
subcommand "
|
74
|
+
desc "label <command>", "Leverage Labels API"
|
75
|
+
subcommand "label", GithubCLI::Commands::Labels
|
77
76
|
|
78
|
-
desc "
|
79
|
-
subcommand "
|
77
|
+
desc "tag <command>", "Leverage Tags API"
|
78
|
+
subcommand "tag", GithubCLI::Commands::Tags
|
80
79
|
|
81
|
-
desc "tree <command>", "
|
82
|
-
subcommand "tree", GithubCLI::Trees
|
80
|
+
desc "tree <command>", "Leverage Trees API"
|
81
|
+
subcommand "tree", GithubCLI::Commands::Trees
|
83
82
|
|
84
83
|
desc 'version', 'Display Github CLI version.'
|
85
84
|
def version
|
@@ -1,9 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'github_cli/command'
|
4
|
-
|
5
3
|
module GithubCLI
|
6
|
-
class Labels < Command
|
4
|
+
class Commands::Labels < Command
|
7
5
|
|
8
6
|
namespace :label
|
9
7
|
|
@@ -22,7 +20,7 @@ module GithubCLI
|
|
22
20
|
end
|
23
21
|
|
24
22
|
method_option :name, :type => :string, :required => true
|
25
|
-
desc 'update <user>, <repo>', '
|
23
|
+
desc 'update <user>, <repo>', 'Update a label.'
|
26
24
|
method_option :params, :type => :hash
|
27
25
|
def update(user, repo)
|
28
26
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
class Commands::Tags < Command
|
5
|
+
|
6
|
+
namespace :tag
|
7
|
+
|
8
|
+
desc 'get <user> <repo> <sha>', 'Get a Tag'
|
9
|
+
method_option :recursive, :type => :boolean, :aliases => ["-r"],
|
10
|
+
:desc => 'get a tree recursively'
|
11
|
+
method_option :params, :type => :hash, :default => {},
|
12
|
+
:desc => 'Additonal request parameters e.i per_page:100'
|
13
|
+
def get(user, repo, sha)
|
14
|
+
Tag.get user, repo, sha, options[:params]
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'create <user> <repo>', 'Create a Tag Object'
|
18
|
+
method_option :params, :type => :hash, :default => {},
|
19
|
+
:desc => 'Additonal request parameters e.i per_page:100'
|
20
|
+
def create(user, repo)
|
21
|
+
Tag.create user, repo, options[:params]
|
22
|
+
end
|
23
|
+
|
24
|
+
end # Tag
|
25
|
+
end # GithubCLI
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
module Commands
|
5
|
+
autoload :Blobs, 'github_cli/commands/blobs'
|
6
|
+
autoload :Issues, 'github_cli/commands/issues'
|
7
|
+
autoload :Labels, 'github_cli/commands/labels'
|
8
|
+
autoload :Repositories, 'github_cli/commands/repositories'
|
9
|
+
autoload :Tags, 'github_cli/commands/tags'
|
10
|
+
autoload :Trees, 'github_cli/commands/trees'
|
11
|
+
end # Commands
|
12
|
+
end # GithubCLI
|
data/lib/github_cli/config.rb
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
module GithubCLI
|
4
4
|
class Config
|
5
5
|
COMMAND_KEY = 'commands'
|
6
|
+
COMMAND_HELP = 'help'
|
6
7
|
|
7
8
|
def initialize(config_filename=nil)
|
8
|
-
@filename = config_filename ||
|
9
|
+
@filename = config_filename || local_options_file
|
9
10
|
end
|
10
11
|
|
11
12
|
def []=(key, value)
|
@@ -32,7 +33,7 @@ module GithubCLI
|
|
32
33
|
def save(config)
|
33
34
|
config[COMMAND_KEY] = {}
|
34
35
|
Command.all.each do |cmd|
|
35
|
-
if !cmd.namespace.empty? && cmd.name !=
|
36
|
+
if !cmd.namespace.empty? && cmd.name != COMMAND_HELP
|
36
37
|
config[COMMAND_KEY]["#{cmd.namespace}-#{cmd.name}"] = { }
|
37
38
|
end
|
38
39
|
end
|
@@ -60,6 +61,22 @@ module GithubCLI
|
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
64
|
+
def custom_options_file
|
65
|
+
end
|
66
|
+
|
67
|
+
def local_options_file
|
68
|
+
'.githubrc'
|
69
|
+
end
|
70
|
+
|
71
|
+
def global_options_file
|
72
|
+
begin
|
73
|
+
File.join Thor::Util.user_home, ".githubrc"
|
74
|
+
rescue ArgumentError
|
75
|
+
GithubCLI.ui.warn "Unable to find ~/.githubrc because the HOME environment variable is not set"
|
76
|
+
nil
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
63
80
|
def set_key(key, value)
|
64
81
|
unless data[key] == value
|
65
82
|
data[key] = value
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module GithubCLI
|
4
|
+
module DSL
|
5
|
+
@@program_name = $0.split(/\//)[-1]
|
6
|
+
@@error_block = nil
|
7
|
+
|
8
|
+
# Defines a program name.
|
9
|
+
def program_name(name=nil)
|
10
|
+
if name
|
11
|
+
@@program_name = name
|
12
|
+
end
|
13
|
+
@@program_name
|
14
|
+
end
|
15
|
+
|
16
|
+
# Defines behaviour on error.
|
17
|
+
def on_error(&block)
|
18
|
+
@@error_block = block
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/github_cli/terminal.rb
CHANGED
@@ -10,14 +10,40 @@ module GithubCLI
|
|
10
10
|
attr_accessor :size
|
11
11
|
|
12
12
|
def print_commands(pattern=nil)
|
13
|
-
GithubCLI.ui.info
|
14
|
-
|
15
|
-
|
13
|
+
GithubCLI.ui.info "Commands:"
|
14
|
+
|
15
|
+
commands = Command.all.select do |cmd|
|
16
|
+
cmd if pattern && cmd.namespace =~ pattern
|
17
|
+
end.map do |cmd|
|
18
|
+
build_command cmd
|
19
|
+
end
|
20
|
+
|
21
|
+
if !commands.empty?
|
22
|
+
GithubCLI.ui.print_table commands, :truncate => true
|
23
|
+
else
|
24
|
+
print_command_not_found pattern.to_s.gsub(/\W|/, '')[3..-1]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_command(cmd, indent=3)
|
29
|
+
prefix = " " * indent
|
30
|
+
if cmd.namespace.empty?
|
31
|
+
["#{prefix + cmd.usage}", cmd.desc]
|
32
|
+
else
|
33
|
+
["#{prefix + cmd.namespace} #{cmd.usage}", cmd.desc]
|
16
34
|
end
|
17
35
|
end
|
18
36
|
|
19
|
-
def
|
20
|
-
GithubCLI.ui.info "
|
37
|
+
def print_command_not_found(cmd)
|
38
|
+
GithubCLI.ui.info "ghc: '#{cmd}' is not a ghc command. See 'ghc --help'."
|
39
|
+
end
|
40
|
+
|
41
|
+
def print_program_name
|
42
|
+
GithubCLI.ui.info <<-TEXT
|
43
|
+
|
44
|
+
#{GithubCLI.program_name}
|
45
|
+
|
46
|
+
TEXT
|
21
47
|
end
|
22
48
|
end
|
23
49
|
|
data/lib/github_cli/ui.rb
CHANGED
data/lib/github_cli/version.rb
CHANGED
data/lib/github_cli.rb
CHANGED
@@ -7,21 +7,20 @@ require 'github_api'
|
|
7
7
|
require 'github_cli/version'
|
8
8
|
|
9
9
|
module GithubCLI
|
10
|
-
autoload :
|
11
|
-
autoload :
|
12
|
-
autoload :
|
13
|
-
autoload :
|
14
|
-
autoload :
|
15
|
-
autoload :
|
16
|
-
autoload :
|
17
|
-
autoload :
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
require "github_cli/command"
|
10
|
+
autoload :DSL, 'github_cli/dsl'
|
11
|
+
autoload :Config, 'github_cli/config'
|
12
|
+
autoload :CLI, 'github_cli/cli'
|
13
|
+
autoload :Command, 'github_cli/command'
|
14
|
+
autoload :API, 'github_cli/api'
|
15
|
+
autoload :Terminal, 'github_cli/terminal'
|
16
|
+
autoload :Commands, 'github_cli/commands'
|
17
|
+
autoload :UI, 'github_cli/ui'
|
18
|
+
|
19
|
+
require 'github_cli/apis'
|
20
|
+
|
21
|
+
extend DSL
|
22
|
+
|
23
|
+
program_name 'Github CLI client'
|
25
24
|
|
26
25
|
class << self
|
27
26
|
attr_writer :ui, :config
|
@@ -2,10 +2,11 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe GithubCLI::Config do
|
4
4
|
let(:filename) { '.githubrc' }
|
5
|
+
let(:config_name) { 'simple_config' }
|
5
6
|
let(:path) { "/users/#{filename}" }
|
6
7
|
|
7
8
|
context 'global' do
|
8
|
-
let(:config) { GithubCLI::Config.new
|
9
|
+
let(:config) { GithubCLI::Config.new fixture_path(config_name) }
|
9
10
|
|
10
11
|
before do
|
11
12
|
File.stub(:open) { YAML.load fixture('simple_config') }
|
@@ -89,6 +90,7 @@ describe GithubCLI::Config do
|
|
89
90
|
end
|
90
91
|
|
91
92
|
it 'expands relative path' do
|
93
|
+
config = GithubCLI::Config.new
|
92
94
|
config.path.should == "#{ENV['HOME']}/#{filename}"
|
93
95
|
end
|
94
96
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,5 +11,9 @@ RSpec.configure do |config|
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def fixture(name)
|
14
|
-
File.read
|
14
|
+
File.read File.expand_path File.join(File.dirname(__FILE__), '..', 'fixtures', name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def fixture_path(name)
|
18
|
+
File.expand_path File.join(File.dirname(__FILE__), '..', 'fixtures', name)
|
15
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: github_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: github_api
|
16
|
-
requirement: &
|
16
|
+
requirement: &2151931920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2151931920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: thor
|
27
|
-
requirement: &
|
27
|
+
requirement: &2151931300 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2151931300
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &2151930280 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2151930280
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: aruba
|
49
|
-
requirement: &
|
49
|
+
requirement: &2151929540 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2151929540
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &2151928740 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2151928740
|
69
69
|
description: CLI-based access to GitHub API v3
|
70
70
|
email:
|
71
71
|
- pmurach@gmail.com
|
@@ -93,18 +93,23 @@ files:
|
|
93
93
|
- github_cli.gemspec
|
94
94
|
- lib/github_cli.rb
|
95
95
|
- lib/github_cli/api.rb
|
96
|
-
- lib/github_cli/
|
97
|
-
- lib/github_cli/
|
96
|
+
- lib/github_cli/apis.rb
|
97
|
+
- lib/github_cli/apis/blob.rb
|
98
|
+
- lib/github_cli/apis/repository.rb
|
99
|
+
- lib/github_cli/apis/tag.rb
|
100
|
+
- lib/github_cli/apis/tree.rb
|
98
101
|
- lib/github_cli/cli.rb
|
99
102
|
- lib/github_cli/command.rb
|
103
|
+
- lib/github_cli/commands.rb
|
104
|
+
- lib/github_cli/commands/blobs.rb
|
105
|
+
- lib/github_cli/commands/issues.rb
|
106
|
+
- lib/github_cli/commands/labels.rb
|
107
|
+
- lib/github_cli/commands/repositories.rb
|
108
|
+
- lib/github_cli/commands/tags.rb
|
109
|
+
- lib/github_cli/commands/trees.rb
|
100
110
|
- lib/github_cli/config.rb
|
101
|
-
- lib/github_cli/
|
102
|
-
- lib/github_cli/labels.rb
|
103
|
-
- lib/github_cli/repositories.rb
|
104
|
-
- lib/github_cli/repository.rb
|
111
|
+
- lib/github_cli/dsl.rb
|
105
112
|
- lib/github_cli/terminal.rb
|
106
|
-
- lib/github_cli/tree.rb
|
107
|
-
- lib/github_cli/trees.rb
|
108
113
|
- lib/github_cli/ui.rb
|
109
114
|
- lib/github_cli/version.rb
|
110
115
|
- spec/github_cli/api_spec.rb
|
File without changes
|
File without changes
|