gboom 0.0.4 → 0.0.5
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/bin/gboom +19 -5
- data/lib/gboom/version.rb +1 -1
- metadata +1 -1
data/bin/gboom
CHANGED
@@ -11,7 +11,7 @@ program_desc 'Create Gists from your command line like a pimp.'
|
|
11
11
|
version GBoom::VERSION
|
12
12
|
|
13
13
|
desc "Create a Gist from an existing file. You just gboom'ed!"
|
14
|
-
arg_name '[path to file]'
|
14
|
+
arg_name '[path to file] [start_line] [end_line]'
|
15
15
|
command :add do |c|
|
16
16
|
c.desc 'Use this flag to hide your embarassing code. Refactor that shit.'
|
17
17
|
c.arg_name 'public'
|
@@ -23,12 +23,26 @@ command :add do |c|
|
|
23
23
|
c.default_value ''
|
24
24
|
c.flag :d
|
25
25
|
|
26
|
-
c.
|
27
|
-
|
28
|
-
|
26
|
+
c.desc ''
|
27
|
+
c.arg_name 'lines'
|
28
|
+
c.default_value ''
|
29
|
+
c.flag [:l, :lines]
|
29
30
|
|
31
|
+
c.action do |global_options,options,args|
|
30
32
|
begin
|
33
|
+
file = args[0]
|
34
|
+
start_line = args[1].to_i
|
35
|
+
end_line = args[2].to_i
|
36
|
+
|
31
37
|
content = File.open(file, 'r') {|f| f.read}
|
38
|
+
start_line = start_line == 0 ? 1 : start_line
|
39
|
+
end_line = end_line > 0 ? end_line : content.lines.count
|
40
|
+
|
41
|
+
raise "Is your shit backwards?" if start_line > end_line
|
42
|
+
raise "Start at 1 buddy." if start_line == 0 && end_line > 0
|
43
|
+
raise "You need to specify a file. C'mon man." unless file
|
44
|
+
content = content.lines.to_a.slice(start_line-1, end_line-start_line+1).join
|
45
|
+
|
32
46
|
file_name = File.basename(file)
|
33
47
|
rescue
|
34
48
|
raise "Unable to read file. Dude, you're fucking this up."
|
@@ -38,7 +52,7 @@ command :add do |c|
|
|
38
52
|
env_username = ENV['GITHUB_USERNAME']
|
39
53
|
env_password = ENV['GITHUB_PASSWORD']
|
40
54
|
username = env_username.nil? || env_username.empty? ? `git config --global --get github.user` : env_username
|
41
|
-
password = env_password.nil? || env_password.empty ? `git config --global --get github.password` : env_password
|
55
|
+
password = env_password.nil? || env_password.empty? ? `git config --global --get github.password` : env_password
|
42
56
|
|
43
57
|
raise "You probably didn't read the instructions did you? You can't just skip to the good stuff, setup your github credentials. Noob." if username.empty? || password.empty?
|
44
58
|
github = Github.new basic_auth: "#{username.strip}:#{password.strip}"
|
data/lib/gboom/version.rb
CHANGED