sem 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcf97334c5552314453331d55eff0abdf5dcb0a7
4
- data.tar.gz: c53b9c7001b91e8bd888e77d88759b5627afde8b
3
+ metadata.gz: '0900f588e0384c8da87f63337d834aaf756126d2'
4
+ data.tar.gz: 6d3ab0baf63f3fe179c3401fd908e947e84bb088
5
5
  SHA512:
6
- metadata.gz: c706b748e6920848e71318d3ae91f009eec005d6fb9fefa24a5a9621908ad7d6e798a29dda0417c5461652f7ff56234ca213dc6622e24cd4b01d3d963dc57c8a
7
- data.tar.gz: 9a705290418c713cee873bf311c932ade36afb76af077cda2f0c36df666cf111359162e304adb720b683a7a326ce2821b5901bd52ef5f73a6ddbc462da7f1bb9
6
+ metadata.gz: 31977a66dc8e11adf8cc170e46ea82ebe8f416f45472f06d0ccdeddd92fa207d5c98b07a718c77c2fb56999127459f265ab8919ac68851ffb4125f50fa7d8159
7
+ data.tar.gz: 0c1d2fd2e7f36207cc2905dcbbed780e5aeb77d0ec68957bda55218941b4656a6458226c71d61826eb9e4555c05f57e269e615f4c9973aa458f157ad00fa408e
data/lib/sem.rb CHANGED
@@ -4,6 +4,7 @@ require "semaphore_client"
4
4
  require "fileutils"
5
5
  require "pmap"
6
6
  require "delegate"
7
+ require "sem/core_ext/string.rb"
7
8
 
8
9
  module Sem
9
10
  require "sem/helpers"
@@ -15,13 +15,14 @@ module Sem
15
15
  desc "login", "Log in to Semaphore from the command line"
16
16
  option "auth-token", :required => true
17
17
  long_desc <<-DESC
18
- Examples:
18
+ Examples:
19
19
 
20
- $ sem login --auth-token abcd12345
21
- Your credentials have been saved to #{Sem::Configuration::CREDENTIALS_PATH}."
20
+ $ sem login --auth-token abcd12345
21
+ Your credentials have been saved to #{Sem::Configuration::CREDENTIALS_PATH}."
22
22
 
23
- You can find your auth-token on the bottom of the users settings page <https://semaphoreci.com/users/edit>.
24
- DESC
23
+ You can find your auth-token on the bottom of the users
24
+ settings page <https://semaphoreci.com/users/edit>.
25
+ DESC
25
26
  def login
26
27
  auth_token = options["auth-token"]
27
28
 
@@ -36,11 +37,11 @@ DESC
36
37
 
37
38
  desc "logout", "Log out from semaphore"
38
39
  long_desc <<-DESC
39
- Examples:
40
+ Examples:
40
41
 
41
- $ sem logout
42
- Logged out.
43
- DESC
42
+ $ sem logout
43
+ Logged out.
44
+ DESC
44
45
  def logout
45
46
  Sem::Configuration.delete_auth_token
46
47
 
@@ -1,14 +1,14 @@
1
1
  class Sem::CLI::Orgs < Dracula
2
2
 
3
3
  desc "list", "List all organizations"
4
- long_desc <<-DESC
5
- Examples:
6
-
7
- $ sem orgs:list
8
- ID NAME
9
- 5bc7ed43-ac8a-487e-b488-c38bc757a034 renderedtext
10
- 99c7ed43-ac8a-487e-b488-c38bc757a034 z-fighters
11
- DESC
4
+ long_desc <<-DESC.strip_heredoc
5
+ Examples:
6
+
7
+ $ sem orgs:list
8
+ ID NAME
9
+ 5bc7ed43-ac8a-487e-b488-c38bc757a034 renderedtext
10
+ 99c7ed43-ac8a-487e-b488-c38bc757a034 z-fighters
11
+ DESC
12
12
  def list
13
13
  orgs = Sem::API::Org.all
14
14
 
@@ -20,15 +20,15 @@ DESC
20
20
  end
21
21
 
22
22
  desc "info", "shows detailed information about an organization"
23
- long_desc <<-DESC
24
- Examples:
25
-
26
- $ sem orgs:info renderedtext
27
- ID 5bc7ed43-ac8a-487e-b488-c38bc757a034
28
- Name renderedtext
29
- Created 2017-08-01 13:14:40 +0200
30
- Updated 2017-08-02 13:14:40 +0200
31
- DESC
23
+ long_desc <<-DESC.strip_heredoc
24
+ Examples:
25
+
26
+ $ sem orgs:info renderedtext
27
+ ID 5bc7ed43-ac8a-487e-b488-c38bc757a034
28
+ Name renderedtext
29
+ Created 2017-08-01 13:14:40 +0200
30
+ Updated 2017-08-02 13:14:40 +0200
31
+ DESC
32
32
  def info(org_name)
33
33
  org = Sem::API::Org.find!(org_name)
34
34
 
@@ -36,15 +36,15 @@ DESC
36
36
  end
37
37
 
38
38
  desc "members", "list members of an organization"
39
- long_desc <<-DESC
40
- Examples:
41
-
42
- $ sem orgs:members renderedtext
43
- NAME
44
- darko
45
- shiroyasha
46
- bmarkons
47
- DESC
39
+ long_desc <<-DESC.strip_heredoc
40
+ Examples:
41
+
42
+ $ sem orgs:members renderedtext
43
+ NAME
44
+ darko
45
+ shiroyasha
46
+ bmarkons
47
+ DESC
48
48
  def members(org_name)
49
49
  org = Sem::API::Org.find!(org_name)
50
50
 
@@ -1,15 +1,15 @@
1
1
  class Sem::CLI::Projects < Dracula
2
2
 
3
3
  desc "list", "list all your projects"
4
- long_desc <<-DESC
5
- Examples:
6
-
7
- $ sem projects:list
8
- NAME
9
- ID NAME
10
- 99c7ed43-ac8a-487e-b488-c38bc757a034 rt/cli
11
- 99c7ed43-ac8a-487e-b488-c38bc757a034 rt/api
12
- DESC
4
+ long_desc <<-DESC.strip_heredoc
5
+ Examples:
6
+
7
+ $ sem projects:list
8
+ NAME
9
+ ID NAME
10
+ 99c7ed43-ac8a-487e-b488-c38bc757a034 rt/cli
11
+ 99c7ed43-ac8a-487e-b488-c38bc757a034 rt/api
12
+ DESC
13
13
  def list
14
14
  projects = Sem::API::Project.all
15
15
 
@@ -21,15 +21,15 @@ DESC
21
21
  end
22
22
 
23
23
  desc "info", "shows detailed information about a project"
24
- long_desc <<-DESC
25
- Examples:
26
-
27
- $ sem projects:info renderedtext/cli
28
- ID 99c7ed43-ac8a-487e-b488-c38bc757a034
29
- Name renderedtext/cli
30
- Created 2017-08-01 13:14:40 +0200
31
- Updated 2017-08-02 13:14:40 +0200
32
- DESC
24
+ long_desc <<-DESC.strip_heredoc
25
+ Examples:
26
+
27
+ $ sem projects:info renderedtext/cli
28
+ ID 99c7ed43-ac8a-487e-b488-c38bc757a034
29
+ Name renderedtext/cli
30
+ Created 2017-08-01 13:14:40 +0200
31
+ Updated 2017-08-02 13:14:40 +0200
32
+ DESC
33
33
  def info(project_name)
34
34
  project = Sem::API::Project.find!(project_name)
35
35
 
@@ -38,27 +38,27 @@ DESC
38
38
 
39
39
  desc "create", "create a project"
40
40
  option :url, :aliases => "-u", :desc => "Git url to the repository", :required => true
41
- long_desc <<-DESC
42
- Examples:
43
-
44
- $ sem projects:create renderedtext/cli --url git@github.com:renderedtext/cli.git
45
- ID 99c7ed43-ac8a-487e-b488-c38bc757a034
46
- Name renderedtext/cli
47
- Created 2017-08-01 13:14:40 +0200
48
- Updated 2017-08-02 13:14:40 +0200
49
-
50
- $ sem projects:create renderedtext/api --url https://github.com/renderedtext/api
51
- ID 99c7ed43-ac8a-487e-b488-c38bc757a034
52
- Name renderedtext/api
53
- Created 2017-08-01 13:14:40 +0200
54
- Updated 2017-08-02 13:14:40 +0200
55
-
56
- $ sem projects:create renderedtext/api-tests --url https://github.com/renderedtext/api
57
- ID 99c7ed43-ac8a-487e-b488-c38bc757a034
58
- Name renderedtext/api-tests
59
- Created 2017-08-01 13:14:40 +0200
60
- Updated 2017-08-02 13:14:40 +0200
61
- DESC
41
+ long_desc <<-DESC.strip_heredoc
42
+ Examples:
43
+
44
+ $ sem projects:create renderedtext/cli --url git@github.com:renderedtext/cli.git
45
+ ID 99c7ed43-ac8a-487e-b488-c38bc757a034
46
+ Name renderedtext/cli
47
+ Created 2017-08-01 13:14:40 +0200
48
+ Updated 2017-08-02 13:14:40 +0200
49
+
50
+ $ sem projects:create renderedtext/api --url https://github.com/renderedtext/api
51
+ ID 99c7ed43-ac8a-487e-b488-c38bc757a034
52
+ Name renderedtext/api
53
+ Created 2017-08-01 13:14:40 +0200
54
+ Updated 2017-08-02 13:14:40 +0200
55
+
56
+ $ sem projects:create renderedtext/api-tests --url https://github.com/renderedtext/api
57
+ ID 99c7ed43-ac8a-487e-b488-c38bc757a034
58
+ Name renderedtext/api-tests
59
+ Created 2017-08-01 13:14:40 +0200
60
+ Updated 2017-08-02 13:14:40 +0200
61
+ DESC
62
62
  def create(project_name)
63
63
  url = Sem::Helpers::GitUrl.new(options[:url])
64
64
 
@@ -78,14 +78,14 @@ DESC
78
78
  class Files < Dracula
79
79
 
80
80
  desc "list", "list configuration files for a project"
81
- long_desc <<-DESC
82
- Examples:
83
-
84
- $ sem projects:files:list renderedtext/cli
85
- ID PATH ENCRYPTED?
86
- 77c7ed43-ac8a-487e-b488-c38bc757a034 /etc/a true
87
- 11c7ed43-bc8a-a87e-ba88-a38ba757a034 /var/secrets.txt true
88
- DESC
81
+ long_desc <<-DESC.strip_heredoc
82
+ Examples:
83
+
84
+ $ sem projects:files:list renderedtext/cli
85
+ ID PATH ENCRYPTED?
86
+ 77c7ed43-ac8a-487e-b488-c38bc757a034 /etc/a true
87
+ 11c7ed43-bc8a-a87e-ba88-a38ba757a034 /var/secrets.txt true
88
+ DESC
89
89
  def list(project_name)
90
90
  project = Sem::API::Project.find!(project_name)
91
91
 
@@ -97,14 +97,14 @@ DESC
97
97
  class EnvVars < Dracula
98
98
 
99
99
  desc "list", "list environment variables on project"
100
- long_desc <<-DESC
101
- Examples:
102
-
103
- $ sem projects:env-vars:list renderedtext/cli
104
- ID NAME ENCRYPTED? CONTENT
105
- 9997ed43-ac8a-487e-b488-c38bc757a034 SECRET false aaa
106
- 1117ed43-tc8a-387e-6488-838bc757a034 TOKEN true *encrypted*
107
- DESC
100
+ long_desc <<-DESC.strip_heredoc
101
+ Examples:
102
+
103
+ $ sem projects:env-vars:list renderedtext/cli
104
+ ID NAME ENCRYPTED? CONTENT
105
+ 9997ed43-ac8a-487e-b488-c38bc757a034 SECRET false aaa
106
+ 1117ed43-tc8a-387e-6488-838bc757a034 TOKEN true *encrypted*
107
+ DESC
108
108
  def list(project_name)
109
109
  project = Sem::API::Project.find!(project_name)
110
110
 
@@ -116,14 +116,14 @@ DESC
116
116
  class Secrets < Dracula
117
117
 
118
118
  desc "list", "list secrets on a project"
119
- long_desc <<-DESC
120
- Examples:
121
-
122
- $ sem projects:secrets:list renderedtext/cli
123
- ID NAME CONFIG FILES ENV VARS
124
- 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
125
- 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/secrets 0 1
126
- DESC
119
+ long_desc <<-DESC.strip_heredoc
120
+ Examples:
121
+
122
+ $ sem projects:secrets:list renderedtext/cli
123
+ ID NAME CONFIG FILES ENV VARS
124
+ 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
125
+ 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/secrets 0 1
126
+ DESC
127
127
  def list(project_name)
128
128
  project = Sem::API::Project.find!(project_name)
129
129
  secrets = project.secrets
@@ -136,12 +136,12 @@ DESC
136
136
  end
137
137
 
138
138
  desc "add", "attach a secret to a project"
139
- long_desc <<-DESC
140
- Examples:
139
+ long_desc <<-DESC.strip_heredoc
140
+ Examples:
141
141
 
142
- $ sem projects:secrets:add renderedtext/cli renderedtext/secrets
143
- Secret renderedtext/secrets added to the project.
144
- DESC
142
+ $ sem projects:secrets:add renderedtext/cli renderedtext/secrets
143
+ Secret renderedtext/secrets added to the project.
144
+ DESC
145
145
  def add(project_name, secret_name)
146
146
  project = Sem::API::Project.find!(project_name)
147
147
  secret = Sem::API::Secret.find!(secret_name)
@@ -152,12 +152,12 @@ DESC
152
152
  end
153
153
 
154
154
  desc "remove", "removes a secret from the project"
155
- long_desc <<-DESC
156
- Examples:
155
+ long_desc <<-DESC.strip_heredoc
156
+ Examples:
157
157
 
158
- $ sem projects:secrets:remove renderedtext/cli renderedtext/secrets
159
- Secret renderedtext/secrets removed from the project.
160
- DESC
158
+ $ sem projects:secrets:remove renderedtext/cli renderedtext/secrets
159
+ Secret renderedtext/secrets removed from the project.
160
+ DESC
161
161
  def remove(project_name, secret_name)
162
162
  project = Sem::API::Project.find!(project_name)
163
163
  secret = Sem::API::Secret.find!(secret_name)
@@ -1,14 +1,14 @@
1
1
  class Sem::CLI::Secrets < Dracula
2
2
 
3
3
  desc "list", "list secrets"
4
- long_desc <<-DESC
5
- Examples:
6
-
7
- $ sem secrets:list
8
- ID NAME CONFIG FILES ENV VARS
9
- 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
10
- 1133ed43-ac8a-487e-b488-c38bc757a044 renderedtext/secrets 0 1
11
- DESC
4
+ long_desc <<-DESC.strip_heredoc
5
+ Examples:
6
+
7
+ $ sem secrets:list
8
+ ID NAME CONFIG FILES ENV VARS
9
+ 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
10
+ 1133ed43-ac8a-487e-b488-c38bc757a044 renderedtext/secrets 0 1
11
+ DESC
12
12
  def list
13
13
  secrets = Sem::API::Secret.all
14
14
 
@@ -20,17 +20,17 @@ DESC
20
20
  end
21
21
 
22
22
  desc "info", "show information about secrets"
23
- long_desc <<-DESC
24
- Examples:
25
-
26
- $ sem secrets:info renderedtext/tokens
27
- ID 99c7ed43-ac8a-487e-b488-c38bc757a034
28
- Name renderedtext/tokens
29
- Config Files 1
30
- Environment Variables 0
31
- Created 2017-08-01 13:14:40 +0200
32
- Updated 2017-08-02 13:14:40 +0200
33
- DESC
23
+ long_desc <<-DESC.strip_heredoc
24
+ Examples:
25
+
26
+ $ sem secrets:info renderedtext/tokens
27
+ ID 99c7ed43-ac8a-487e-b488-c38bc757a034
28
+ Name renderedtext/tokens
29
+ Config Files 1
30
+ Environment Variables 0
31
+ Created 2017-08-01 13:14:40 +0200
32
+ Updated 2017-08-02 13:14:40 +0200
33
+ DESC
34
34
  def info(secret_name)
35
35
  secret = Sem::API::Secret.find!(secret_name)
36
36
 
@@ -38,17 +38,17 @@ DESC
38
38
  end
39
39
 
40
40
  desc "create", "create new secrets"
41
- long_desc <<-DESC
42
- Examples:
43
-
44
- $ sem secrets:create renderedtext/tokens
45
- ID 99c7ed43-ac8a-487e-b488-c38bc757a034
46
- Name renderedtext/tokens
47
- Config Files 1
48
- Environment Variables 0
49
- Created 2017-08-01 13:14:40 +0200
50
- Updated 2017-08-02 13:14:40 +0200
51
- DESC
41
+ long_desc <<-DESC.strip_heredoc
42
+ Examples:
43
+
44
+ $ sem secrets:create renderedtext/tokens
45
+ ID 99c7ed43-ac8a-487e-b488-c38bc757a034
46
+ Name renderedtext/tokens
47
+ Config Files 1
48
+ Environment Variables 0
49
+ Created 2017-08-01 13:14:40 +0200
50
+ Updated 2017-08-02 13:14:40 +0200
51
+ DESC
52
52
  def create(secret_name)
53
53
  secret = Sem::API::Secret.create!(secret_name)
54
54
 
@@ -56,17 +56,17 @@ DESC
56
56
  end
57
57
 
58
58
  desc "rename", "rename secrets"
59
- long_desc <<-DESC
60
- Examples:
61
-
62
- $ sem secrets:create renderedtext/tokens renderedtext/psst
63
- ID 99c7ed43-ac8a-487e-b488-c38bc757a034
64
- Name renderedtext/psst
65
- Config Files 1
66
- Environment Variables 0
67
- Created 2017-08-01 13:14:40 +0200
68
- Updated 2017-08-02 13:14:40 +0200
69
- DESC
59
+ long_desc <<-DESC.strip_heredoc
60
+ Examples:
61
+
62
+ $ sem secrets:create renderedtext/tokens renderedtext/psst
63
+ ID 99c7ed43-ac8a-487e-b488-c38bc757a034
64
+ Name renderedtext/psst
65
+ Config Files 1
66
+ Environment Variables 0
67
+ Created 2017-08-01 13:14:40 +0200
68
+ Updated 2017-08-02 13:14:40 +0200
69
+ DESC
70
70
  def rename(old_secrets_name, new_secrets_name)
71
71
  old_org_name, _old_name = Sem::SRN.parse_secret(old_secrets_name)
72
72
  new_org_name, new_name = Sem::SRN.parse_secret(new_secrets_name)
@@ -80,12 +80,12 @@ DESC
80
80
  end
81
81
 
82
82
  desc "delete", "removes secrets from your organization"
83
- long_desc <<-DESC
84
- Examples:
83
+ long_desc <<-DESC.strip_heredoc
84
+ Examples:
85
85
 
86
- $ sem secrets:delete renderedtext/tokens
87
- Deleted secret renderedtext/tokens.
88
- DESC
86
+ $ sem secrets:delete renderedtext/tokens
87
+ Deleted secret renderedtext/tokens.
88
+ DESC
89
89
  def delete(secrets_name)
90
90
  secret = Sem::API::Secret.find!(secrets_name)
91
91
  secret.delete!
@@ -96,14 +96,14 @@ DESC
96
96
  class Files < Dracula
97
97
 
98
98
  desc "list", "list files in secrets"
99
- long_desc <<-DESC
100
- Examples:
101
-
102
- $ sem secrets:files:list renderedtext/tokens
103
- ID PATH ENCRYPTED?
104
- 77c7ed43-ac8a-487e-b488-c38bc757a034 /home/runner/a true
105
- 11c7ed43-bc8a-a87e-ba88-a38ba757a034 /home/runner/secrets.txt true
106
- DESC
99
+ long_desc <<-DESC.strip_heredoc
100
+ Examples:
101
+
102
+ $ sem secrets:files:list renderedtext/tokens
103
+ ID PATH ENCRYPTED?
104
+ 77c7ed43-ac8a-487e-b488-c38bc757a034 /home/runner/a true
105
+ 11c7ed43-bc8a-a87e-ba88-a38ba757a034 /home/runner/secrets.txt true
106
+ DESC
107
107
  def list(secret_name)
108
108
  secret = Sem::API::Secret.find!(secret_name)
109
109
  files = secret.files
@@ -116,14 +116,20 @@ DESC
116
116
  end
117
117
 
118
118
  desc "add", "add a file to secrets"
119
- option "path-on-semaphore", :aliases => "p", :desc => "Path of the file in builds relative to /home/runner directory", :required => true
120
- option "local-path", :aliases => "l", :desc => "Location of the file on the local machine", :required => true
121
- long_desc <<-DESC
122
- Examples:
123
-
124
- $ sem secrets:files:add renderedtext/tokens --local-path /tmp/secrets.json --path-on-semaphore secrets.json
125
- Added /home/runner/secrets.txt to renderedtext/secrets.
126
- DESC
119
+ option "path-on-semaphore",
120
+ :aliases => "p",
121
+ :desc => "Path of the file in builds relative to /home/runner directory",
122
+ :required => true
123
+ option "local-path",
124
+ :aliases => "l",
125
+ :desc => "Location of the file on the local machine",
126
+ :required => true
127
+ long_desc <<-DESC.strip_heredoc
128
+ Examples:
129
+
130
+ $ sem secrets:files:add rt/tokens --local-path /tmp/secrets.json --path-on-semaphore secrets.json
131
+ Added /home/runner/secrets.txt to rt/secrets.
132
+ DESC
127
133
  def add(secrets_name)
128
134
  secret = Sem::API::Secret.find!(secrets_name)
129
135
 
@@ -140,13 +146,16 @@ DESC
140
146
  end
141
147
 
142
148
  desc "remove", "remove a file from secrets"
143
- option :path, :aliases => "p", :desc => "Path of the file in builds relative to /home/runner directory", :required => true
144
- long_desc <<-DESC
145
- Examples:
146
-
147
- $ sem secrets:files:remove renderedtext/secrets --path secrets.json
148
- Removed /home/runner/secrets.txt from renderedtext/secrets.
149
- DESC
149
+ option :path,
150
+ :aliases => "p",
151
+ :desc => "Path of the file in builds relative to /home/runner directory",
152
+ :required => true
153
+ long_desc <<-DESC.strip_heredoc
154
+ Examples:
155
+
156
+ $ sem secrets:files:remove renderedtext/secrets --path secrets.json
157
+ Removed /home/runner/secrets.txt from renderedtext/secrets.
158
+ DESC
150
159
  def remove(secrets_name)
151
160
  secret = Sem::API::Secret.find!(secrets_name)
152
161
 
@@ -160,14 +169,14 @@ DESC
160
169
  class EnvVars < Dracula
161
170
 
162
171
  desc "list", "list environment variables in secrets"
163
- long_desc <<-DESC
164
- Examples:
165
-
166
- $ sem secrets:files:list renderedtext/tokens
167
- ID NAME ENCRYPTED? CONTENT
168
- 9997ed43-ac8a-487e-b488-c38bc757a034 SECRET true aaa
169
- 1117ed43-tc8a-387e-6488-838bc757a034 TOKEN true *encrypted*
170
- DESC
172
+ long_desc <<-DESC.strip_heredoc
173
+ Examples:
174
+
175
+ $ sem secrets:files:list renderedtext/tokens
176
+ ID NAME ENCRYPTED? CONTENT
177
+ 9997ed43-ac8a-487e-b488-c38bc757a034 SECRET true aaa
178
+ 1117ed43-tc8a-387e-6488-838bc757a034 TOKEN true *encrypted*
179
+ DESC
171
180
  def list(secret_name)
172
181
  secret = Sem::API::Secret.find!(secret_name)
173
182
  env_vars = secret.env_vars
@@ -182,12 +191,12 @@ DESC
182
191
  desc "add", "add an environment variable to secrets"
183
192
  option :name, :aliases => "n", :desc => "Name of the variable", :required => true
184
193
  option :content, :aliases => "c", :desc => "Content of the variable", :required => true
185
- long_desc <<-DESC
186
- Examples:
194
+ long_desc <<-DESC.strip_heredoc
195
+ Examples:
187
196
 
188
- $ sem secrets:env-vars:add renderedtext/secrets --name TOKEN --content "s3cr3t"
189
- Added TOKEN to renderedtext/secrets.
190
- DESC
197
+ $ sem secrets:env-vars:add renderedtext/secrets --name TOKEN --content "s3cr3t"
198
+ Added TOKEN to renderedtext/secrets.
199
+ DESC
191
200
  def add(secret_name)
192
201
  secret = Sem::API::Secret.find!(secret_name)
193
202
 
@@ -198,12 +207,12 @@ DESC
198
207
 
199
208
  desc "remove", "remove an environment variable from secrets"
200
209
  option :name, :aliases => "n", :desc => "Name of the variable", :required => true
201
- long_desc <<-DESC
202
- Examples:
210
+ long_desc <<-DESC.strip_heredoc
211
+ Examples:
203
212
 
204
- $ sem secrets:env-vars:remove renderedtext/secrets --name TOKEN
205
- Removed TOKEN from renderedtext/secrets.
206
- DESC
213
+ $ sem secrets:env-vars:remove renderedtext/secrets --name TOKEN
214
+ Removed TOKEN from renderedtext/secrets.
215
+ DESC
207
216
  def remove(secrets_name)
208
217
  secret = Sem::API::Secret.find!(secrets_name)
209
218
  name = options[:name]
@@ -3,14 +3,14 @@ class Sem::CLI::Teams < Dracula # rubocop:disable Metrics/ClassLength
3
3
  ALLOWED_PERMISSIONS = ["admin", "edit", "read"].freeze
4
4
 
5
5
  desc "list", "list all your teams"
6
- long_desc <<-DESC
7
- Examples:
8
-
9
- $ sem teams:list
10
- ID NAME PERMISSION MEMBERS
11
- 1bc7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/devs write 2 members
12
- 1bc7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/admins write 0 members
13
- DESC
6
+ long_desc <<-DESC.strip_heredoc
7
+ Examples:
8
+
9
+ $ sem teams:list
10
+ ID NAME PERMISSION MEMBERS
11
+ 1bc7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/devs write 2 members
12
+ 1bc7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/admins write 0 members
13
+ DESC
14
14
  def list
15
15
  teams = Sem::API::Team.all
16
16
 
@@ -22,17 +22,17 @@ DESC
22
22
  end
23
23
 
24
24
  desc "info", "show information about a team"
25
- long_desc <<-DESC
26
- Examples:
27
-
28
- $ sem teams:info renderedtext/admins
29
- ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
30
- Name renderedtext/admins
31
- Permission edit
32
- Members 2 members
33
- Created 2017-08-01 13:14:40 +0200
34
- Updated 2017-08-02 13:14:40 +0200
35
- DESC
25
+ long_desc <<-DESC.strip_heredoc
26
+ Examples:
27
+
28
+ $ sem teams:info renderedtext/admins
29
+ ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
30
+ Name renderedtext/admins
31
+ Permission edit
32
+ Members 2 members
33
+ Created 2017-08-01 13:14:40 +0200
34
+ Updated 2017-08-02 13:14:40 +0200
35
+ DESC
36
36
  def info(team_name)
37
37
  team = Sem::API::Team.find!(team_name)
38
38
 
@@ -43,33 +43,33 @@ DESC
43
43
  option :permission, :default => "read",
44
44
  :aliases => "p",
45
45
  :desc => "Permission level of the team in the organization"
46
- long_desc <<-DESC
47
- Examples:
48
-
49
- $ sem teams:create renderedtext/interns
50
- ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
51
- Name renderedtext/interns
52
- Permission read
53
- Members 0 members
54
- Created 2017-08-01 13:14:40 +0200
55
- Updated 2017-08-02 13:14:40 +0200
56
-
57
- $ sem teams:create renderedtext/devs --permission edit
58
- ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
59
- Name renderedtext/devs
60
- Permission edit
61
- Members 0 members
62
- Created 2017-08-01 13:14:40 +0200
63
- Updated 2017-08-02 13:14:40 +0200
64
-
65
- $ sem teams:create renderedtext/admins --permission admin
66
- ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
67
- Name renderedtext/admins
68
- Permission admin
69
- Members 0 members
70
- Created 2017-08-01 13:14:40 +0200
71
- Updated 2017-08-02 13:14:40 +0200
72
- DESC
46
+ long_desc <<-DESC.strip_heredoc
47
+ Examples:
48
+
49
+ $ sem teams:create renderedtext/interns
50
+ ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
51
+ Name renderedtext/interns
52
+ Permission read
53
+ Members 0 members
54
+ Created 2017-08-01 13:14:40 +0200
55
+ Updated 2017-08-02 13:14:40 +0200
56
+
57
+ $ sem teams:create renderedtext/devs --permission edit
58
+ ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
59
+ Name renderedtext/devs
60
+ Permission edit
61
+ Members 0 members
62
+ Created 2017-08-01 13:14:40 +0200
63
+ Updated 2017-08-02 13:14:40 +0200
64
+
65
+ $ sem teams:create renderedtext/admins --permission admin
66
+ ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
67
+ Name renderedtext/admins
68
+ Permission admin
69
+ Members 0 members
70
+ Created 2017-08-01 13:14:40 +0200
71
+ Updated 2017-08-02 13:14:40 +0200
72
+ DESC
73
73
  def create(team_name)
74
74
  permission = options[:permission]
75
75
 
@@ -83,17 +83,17 @@ DESC
83
83
  end
84
84
 
85
85
  desc "rename", "change the name of the team"
86
- long_desc <<-DESC
87
- Examples:
88
-
89
- $ sem teams:create renderedtext/interns renderedtext/juniors
90
- ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
91
- Name renderedtext/juniors
92
- Permission read
93
- Members 0 members
94
- Created 2017-08-01 13:14:40 +0200
95
- Updated 2017-08-02 13:14:40 +0200
96
- DESC
86
+ long_desc <<-DESC.strip_heredoc
87
+ Examples:
88
+
89
+ $ sem teams:create renderedtext/interns renderedtext/juniors
90
+ ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
91
+ Name renderedtext/juniors
92
+ Permission read
93
+ Members 0 members
94
+ Created 2017-08-01 13:14:40 +0200
95
+ Updated 2017-08-02 13:14:40 +0200
96
+ DESC
97
97
  def rename(old_team_name, new_team_name)
98
98
  old_org_name, _old_name = Sem::SRN.parse_team(old_team_name)
99
99
  new_org_name, new_name = Sem::SRN.parse_team(new_team_name)
@@ -111,17 +111,17 @@ DESC
111
111
  :required => true,
112
112
  :aliases => "p",
113
113
  :desc => "Permission level of the team in the organization"
114
- long_desc <<-DESC
115
- Examples:
116
-
117
- $ sem teams:set-permission renderedtext/interns --permission edit
118
- ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
119
- Name renderedtext/interns
120
- Permission edit
121
- Members 0 members
122
- Created 2017-08-01 13:14:40 +0200
123
- Updated 2017-08-02 13:14:40 +0200
124
- DESC
114
+ long_desc <<-DESC.strip_heredoc
115
+ Examples:
116
+
117
+ $ sem teams:set-permission renderedtext/interns --permission edit
118
+ ID 1bc7ed43-ac8a-487e-b488-c38bc757a034
119
+ Name renderedtext/interns
120
+ Permission edit
121
+ Members 0 members
122
+ Created 2017-08-01 13:14:40 +0200
123
+ Updated 2017-08-02 13:14:40 +0200
124
+ DESC
125
125
  def set_permission(team_name) # rubocop:disable Style/AccessorMethodName
126
126
  permission = options[:permission]
127
127
 
@@ -136,12 +136,12 @@ DESC
136
136
  end
137
137
 
138
138
  desc "delete", "removes a team from your organization"
139
- long_desc <<-DESC
140
- Examples:
139
+ long_desc <<-DESC.strip_heredoc
140
+ Examples:
141
141
 
142
- $ sem teams:delete renderedtext/interns
143
- Team renderedtext/interns deleted.
144
- DESC
142
+ $ sem teams:delete renderedtext/interns
143
+ Team renderedtext/interns deleted.
144
+ DESC
145
145
  def delete(team_name)
146
146
  team = Sem::API::Team.find!(team_name)
147
147
  team.delete!
@@ -151,15 +151,15 @@ DESC
151
151
 
152
152
  class Members < Dracula
153
153
  desc "list", "list members of the team"
154
- long_desc <<-DESC
155
- Examples:
156
-
157
- $ sem teams:members:list renderedtext/interns
158
- NAME
159
- shiroyasha
160
- darko
161
- ervinb
162
- DESC
154
+ long_desc <<-DESC.strip_heredoc
155
+ Examples:
156
+
157
+ $ sem teams:members:list renderedtext/interns
158
+ NAME
159
+ shiroyasha
160
+ darko
161
+ ervinb
162
+ DESC
163
163
  def list(team_name)
164
164
  team = Sem::API::Team.find!(team_name)
165
165
  users = team.users
@@ -172,12 +172,12 @@ DESC
172
172
  end
173
173
 
174
174
  desc "add", "add a user to the team"
175
- long_desc <<-DESC
176
- Examples:
175
+ long_desc <<-DESC.strip_heredoc
176
+ Examples:
177
177
 
178
- $ sem teams:members:add renderedtext/interns shiroyasha
179
- User shiroyasha added to the team.
180
- DESC
178
+ $ sem teams:members:add renderedtext/interns shiroyasha
179
+ User shiroyasha added to the team.
180
+ DESC
181
181
  def add(team_name, username)
182
182
  team = Sem::API::Team.find!(team_name)
183
183
  team.add_user(username)
@@ -186,12 +186,12 @@ DESC
186
186
  end
187
187
 
188
188
  desc "remove", "remove a user from the team"
189
- long_desc <<-DESC
190
- Examples:
189
+ long_desc <<-DESC.strip_heredoc
190
+ Examples:
191
191
 
192
- $ sem teams:members:remove renderedtext/interns shiroyasha
193
- User shiroyasha removed from the team.
194
- DESC
192
+ $ sem teams:members:remove renderedtext/interns shiroyasha
193
+ User shiroyasha removed from the team.
194
+ DESC
195
195
  def remove(team_name, username)
196
196
  team = Sem::API::Team.find!(team_name)
197
197
  team.remove_user(username)
@@ -202,15 +202,15 @@ DESC
202
202
 
203
203
  class Projects < Dracula
204
204
  desc "list", "list projects in a team"
205
- long_desc <<-DESC
206
- Examples:
207
-
208
- $ sem team:projects:list renderedtext/devs
209
- NAME
210
- ID NAME
211
- 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/cli
212
- 12c7ed43-4444-487e-b488-c38bc757a034 renderedtext/api
213
- DESC
205
+ long_desc <<-DESC.strip_heredoc
206
+ Examples:
207
+
208
+ $ sem team:projects:list renderedtext/devs
209
+ NAME
210
+ ID NAME
211
+ 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/cli
212
+ 12c7ed43-4444-487e-b488-c38bc757a034 renderedtext/api
213
+ DESC
214
214
  def list(team_name)
215
215
  team = Sem::API::Team.find!(team_name)
216
216
  projects = team.projects
@@ -223,12 +223,12 @@ DESC
223
223
  end
224
224
 
225
225
  desc "add", "add a project to a team"
226
- long_desc <<-DESC
227
- Examples:
226
+ long_desc <<-DESC.strip_heredoc
227
+ Examples:
228
228
 
229
- $ sem team:projects:add renderedtext/devs renderedtext/cli
230
- Project renderedtext/cli added to the team.
231
- DESC
229
+ $ sem team:projects:add renderedtext/devs renderedtext/cli
230
+ Project renderedtext/cli added to the team.
231
+ DESC
232
232
  def add(team_name, project_name)
233
233
  team = Sem::API::Team.find!(team_name)
234
234
  project = Sem::API::Project.find!(project_name)
@@ -239,12 +239,12 @@ DESC
239
239
  end
240
240
 
241
241
  desc "remove", "remove a project from the team"
242
- long_desc <<-DESC
243
- Examples:
242
+ long_desc <<-DESC.strip_heredoc
243
+ Examples:
244
244
 
245
- $ sem team:projects:remove renderedtext/devs renderedtext/cli
246
- Project renderedtext/cli removed from the team.
247
- DESC
245
+ $ sem team:projects:remove renderedtext/devs renderedtext/cli
246
+ Project renderedtext/cli removed from the team.
247
+ DESC
248
248
  def remove(team_name, project_name)
249
249
  team = Sem::API::Team.find!(team_name)
250
250
  project = Sem::API::Project.find!(project_name)
@@ -257,14 +257,14 @@ DESC
257
257
 
258
258
  class Secrets < Dracula
259
259
  desc "list", "list secrets in a team"
260
- long_desc <<-DESC
261
- Examples:
262
-
263
- $ sem team:secrets:list renderedtext/devs
264
- ID NAME CONFIG FILES ENV VARS
265
- 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
266
- 1133ed43-ac8a-487e-b488-c38bc757a044 renderedtext/secrets 0 1
267
- DESC
260
+ long_desc <<-DESC.strip_heredoc
261
+ Examples:
262
+
263
+ $ sem team:secrets:list renderedtext/devs
264
+ ID NAME CONFIG FILES ENV VARS
265
+ 99c7ed43-ac8a-487e-b488-c38bc757a034 renderedtext/tokens 1 0
266
+ 1133ed43-ac8a-487e-b488-c38bc757a044 renderedtext/secrets 0 1
267
+ DESC
268
268
  def list(team_name)
269
269
  team = Sem::API::Team.find!(team_name)
270
270
  configs = team.secrets
@@ -277,12 +277,12 @@ DESC
277
277
  end
278
278
 
279
279
  desc "add", "add secrets to a team"
280
- long_desc <<-DESC
281
- Examples:
280
+ long_desc <<-DESC.strip_heredoc
281
+ Examples:
282
282
 
283
- $ sem team:secrets:add renderedtext/devs renderedtext/tokens
284
- Secrets renderedtext/token added to the team.
285
- DESC
283
+ $ sem team:secrets:add renderedtext/devs renderedtext/tokens
284
+ Secrets renderedtext/token added to the team.
285
+ DESC
286
286
  def add(team_name, secret_name)
287
287
  team = Sem::API::Team.find!(team_name)
288
288
  secret = Sem::API::Secret.find!(secret_name)
@@ -293,12 +293,12 @@ DESC
293
293
  end
294
294
 
295
295
  desc "remove", "removes secrets from the team"
296
- long_desc <<-DESC
297
- Examples:
296
+ long_desc <<-DESC.strip_heredoc
297
+ Examples:
298
298
 
299
- $ sem team:secrets:remove renderedtext/devs renderedtext/secrets
300
- Secrets renderedtext/secrets removed from the team.
301
- DESC
299
+ $ sem team:secrets:remove renderedtext/devs renderedtext/secrets
300
+ Secrets renderedtext/secrets removed from the team.
301
+ DESC
302
302
  def remove(team_name, secret_name)
303
303
  team = Sem::API::Team.find!(team_name)
304
304
  secret = Sem::API::Secret.find!(secret_name)
@@ -0,0 +1,35 @@
1
+ class String
2
+ # This was copied from:
3
+ # activesupport/lib/active_support/core_ext/string/strip.rb
4
+ #
5
+ # Instead of importing the whole activesupport library,
6
+ # we are only importing this one method.
7
+ #
8
+ # Is this safe?
9
+ # The assumption is that the CLI will not be included in other
10
+ # projects as a gem. That mitigates possible side effects.
11
+ #
12
+ # ---------------------------------------------------------------------------
13
+ #
14
+ # Strips indentation in heredocs.
15
+ #
16
+ # For example in
17
+ #
18
+ # if options[:usage]
19
+ # puts <<-USAGE.strip_heredoc
20
+ # This command does such and such.
21
+ #
22
+ # Supported options are:
23
+ # -h This message
24
+ # ...
25
+ # USAGE
26
+ # end
27
+ #
28
+ # the user would see the usage message aligned against the left margin.
29
+ #
30
+ # Technically, it looks for the least indented non-empty line
31
+ # in the whole string, and removes that amount of leading whitespace.
32
+ def strip_heredoc
33
+ gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, "".freeze)
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module Sem
2
- VERSION = "0.8.0".freeze
2
+ VERSION = "0.8.1".freeze
3
3
  end
@@ -12,7 +12,7 @@ class Sem::Views::Secrets < Sem::Views::Base
12
12
  def self.list(secrets)
13
13
  header = ["ID", "NAME", "CONFIG FILES", "ENV VARS"]
14
14
 
15
- body = secrets.map do |secret|
15
+ body = secrets.pmap do |secret|
16
16
  [secret.id, secret.full_name, secret.files.count, secret.env_vars.count]
17
17
  end
18
18
 
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "bundler", "~> 1.14"
29
29
  spec.add_development_dependency "rake", "~> 10.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "rubocop", "~> 0.47.1"
31
+ spec.add_development_dependency "rubocop", "~> 0.49.0"
32
32
  spec.add_development_dependency "rubocop-rspec", "1.5.0"
33
33
  spec.add_development_dependency "simplecov", "~> 0.13"
34
34
  spec.add_development_dependency "byebug", "~> 9.0.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Šarčević
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-17 00:00:00.000000000 Z
11
+ date: 2017-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semaphore_client
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.47.1
103
+ version: 0.49.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.47.1
110
+ version: 0.49.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop-rspec
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -214,6 +214,7 @@ files:
214
214
  - lib/sem/cli/secrets.rb
215
215
  - lib/sem/cli/teams.rb
216
216
  - lib/sem/configuration.rb
217
+ - lib/sem/core_ext/string.rb
217
218
  - lib/sem/errors.rb
218
219
  - lib/sem/helpers.rb
219
220
  - lib/sem/helpers/git_url.rb
@@ -249,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
249
250
  version: '0'
250
251
  requirements: []
251
252
  rubyforge_project:
252
- rubygems_version: 2.5.2
253
+ rubygems_version: 2.6.13
253
254
  signing_key:
254
255
  specification_version: 4
255
256
  summary: Semaphore CLI