uffizzi-cli 0.1.4.3 → 0.2.0
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 +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile.lock +5 -1
- data/README.md +67 -26
- data/config/config.rb +17 -0
- data/lib/uffizzi/auth_helper.rb +5 -0
- data/lib/uffizzi/cli/config.rb +28 -20
- data/lib/uffizzi/cli/login.rb +3 -6
- data/lib/uffizzi/cli/preview.rb +267 -0
- data/lib/uffizzi/cli/project/compose.rb +119 -0
- data/lib/uffizzi/cli/project.rb +64 -0
- data/lib/uffizzi/cli.rb +15 -14
- data/lib/uffizzi/clients/api/api_client.rb +71 -5
- data/lib/uffizzi/clients/api/api_routes.rb +24 -0
- data/lib/uffizzi/clients/api/http_client.rb +21 -3
- data/lib/uffizzi/config_file.rb +17 -13
- data/lib/uffizzi/response_helper.rb +24 -0
- data/lib/uffizzi/services/compose_file_service.rb +102 -0
- data/lib/uffizzi/services/env_variables_service.rb +48 -0
- data/lib/uffizzi/version.rb +1 -1
- data/lib/uffizzi.rb +5 -4
- data/man/uffizzi-create +50 -0
- data/man/uffizzi-create.ronn +41 -0
- data/man/uffizzi-delete +37 -0
- data/man/uffizzi-delete.ronn +28 -0
- data/man/uffizzi-describe +38 -0
- data/man/uffizzi-describe.ronn +29 -0
- data/man/uffizzi-list +33 -0
- data/man/uffizzi-list.ronn +25 -0
- data/man/uffizzi-preview +39 -0
- data/man/uffizzi-preview.ronn +33 -0
- data/uffizzi.gemspec +1 -0
- metadata +32 -3
- data/lib/uffizzi/cli/projects.rb +0 -48
data/lib/uffizzi.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'uffizzi/shell'
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
require 'uffizzi/version'
|
5
|
+
require 'uffizzi/clients/api/api_client'
|
6
|
+
require 'uffizzi/clients/api/api_routes'
|
7
|
+
require 'uffizzi/config_file'
|
8
8
|
|
9
9
|
module Uffizzi
|
10
10
|
class Error < StandardError; end
|
11
|
+
|
11
12
|
class << self
|
12
13
|
def ui
|
13
14
|
@ui ||= Uffizzi::UI::Shell.new
|
data/man/uffizzi-create
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
.\" generated with Ronn-NG/v0.9.1
|
2
|
+
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
3
|
+
.TH "CREATE" "" "February 2022" ""
|
4
|
+
.SH "NAME"
|
5
|
+
\fBcreate\fR \- create a preview
|
6
|
+
.SH "SYNOPSIS"
|
7
|
+
.nf
|
8
|
+
uffizzi preview create [COMPOSE_FILE] [UFFIZZI_WIDE_FLAG \|\.\|\.\|\.]
|
9
|
+
.fi
|
10
|
+
.SH "DESCRIPTION"
|
11
|
+
.nf
|
12
|
+
Creates a new preview\. If no COMPOSE_FILE is specified, the preview
|
13
|
+
is created with the project\'s default compose file\.
|
14
|
+
|
15
|
+
This command can fail for the following reasons:
|
16
|
+
\- The project does not have a default compose file set\. Run
|
17
|
+
$ uffizzi compose \-\-help for details\.
|
18
|
+
\- The alternate compose file is invalid\.
|
19
|
+
|
20
|
+
For more information on Uffizzi previews, see:
|
21
|
+
https://docs\.uffizzi\.com/cli/preview
|
22
|
+
.fi
|
23
|
+
.SH "POSITIONAL ARGUMENTS"
|
24
|
+
.nf
|
25
|
+
[COMPOSE_FILE]
|
26
|
+
An alternate compose file to the default compose\.
|
27
|
+
|
28
|
+
You can pass a compose file to this command to create an ad hoc
|
29
|
+
preview of an alternate compose configuration\. The file passed
|
30
|
+
via this argument does not replace the default compose file for
|
31
|
+
the project\. Alternate compose files share the same lifecyle as
|
32
|
+
the previews they create: when the preview is deleted, the
|
33
|
+
alternate compose is deleted by the Uffizzi API\.
|
34
|
+
.fi
|
35
|
+
.SH "UFFIZZI WIDE FLAGS"
|
36
|
+
.nf
|
37
|
+
These flags are available to all commands: \-\-project\. Run $ uffizzi
|
38
|
+
help for details\.
|
39
|
+
.fi
|
40
|
+
.SH "EXAMPLES"
|
41
|
+
.nf
|
42
|
+
To create a preview with the project\'s default compose file, run:
|
43
|
+
|
44
|
+
$ uffizzi preview create
|
45
|
+
|
46
|
+
To create a preview with an alternate compose file, run:
|
47
|
+
|
48
|
+
$ uffizzi preview create docker\-compose\.uffizzi\.alt\.yml
|
49
|
+
.fi
|
50
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
uffizzi preview create - create a preview
|
2
|
+
================================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
uffizzi preview create [COMPOSE_FILE] [UFFIZZI_WIDE_FLAG ...]
|
6
|
+
|
7
|
+
## DESCRIPTION
|
8
|
+
Creates a new preview. If no COMPOSE_FILE is specified, the preview
|
9
|
+
is created with the project's default compose file.
|
10
|
+
|
11
|
+
This command can fail for the following reasons:
|
12
|
+
- The project does not have a default compose file set. Run
|
13
|
+
$ uffizzi compose --help for details.
|
14
|
+
- The alternate compose file is invalid.
|
15
|
+
|
16
|
+
For more information on Uffizzi previews, see:
|
17
|
+
https://docs.uffizzi.com/cli/preview
|
18
|
+
|
19
|
+
## POSITIONAL ARGUMENTS
|
20
|
+
[COMPOSE_FILE]
|
21
|
+
An alternate compose file to the default compose.
|
22
|
+
|
23
|
+
You can pass a compose file to this command to create an ad hoc
|
24
|
+
preview of an alternate compose configuration. The file passed
|
25
|
+
via this argument does not replace the default compose file for
|
26
|
+
the project. Alternate compose files share the same lifecyle as
|
27
|
+
the previews they create: when the preview is deleted, the
|
28
|
+
alternate compose is deleted by the Uffizzi API.
|
29
|
+
|
30
|
+
## UFFIZZI WIDE FLAGS
|
31
|
+
These flags are available to all commands: --project. Run $ uffizzi
|
32
|
+
help for details.
|
33
|
+
|
34
|
+
## EXAMPLES
|
35
|
+
To create a preview with the project's default compose file, run:
|
36
|
+
|
37
|
+
$ uffizzi preview create
|
38
|
+
|
39
|
+
To create a preview with an alternate compose file, run:
|
40
|
+
|
41
|
+
$ uffizzi preview create docker-compose.uffizzi.alt.yml
|
data/man/uffizzi-delete
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
.\" generated with Ronn-NG/v0.9.1
|
2
|
+
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
3
|
+
.TH "DELETE" "" "February 2022" ""
|
4
|
+
.SH "NAME"
|
5
|
+
\fBdelete\fR \- delete a preview
|
6
|
+
.SH "SYNOPSIS"
|
7
|
+
.nf
|
8
|
+
uffizzi preview delete [PREVIEW_ID] [UFFIZZI_WIDE_FLAG \|\.\|\.\|\.]
|
9
|
+
.fi
|
10
|
+
.SH "DESCRIPTION"
|
11
|
+
.nf
|
12
|
+
Deletes a preview with the given preview ID\.
|
13
|
+
|
14
|
+
This command can fail for the following reasons:
|
15
|
+
\- The preview specified does not exist\.
|
16
|
+
\- The preview specified belongs to a different project\.
|
17
|
+
|
18
|
+
For more information on Uffizzi previews, see:
|
19
|
+
https://docs\.uffizzi\.com/cli/preview
|
20
|
+
.fi
|
21
|
+
.SH "POSITIONAL ARGUMENTS"
|
22
|
+
.nf
|
23
|
+
[PREVIEW_ID]
|
24
|
+
ID for the preview you want to delete\.
|
25
|
+
.fi
|
26
|
+
.SH "UFFIZZI WIDE FLAGS"
|
27
|
+
.nf
|
28
|
+
These flags are available to all commands: \-\-project\. Run $ uffizzi
|
29
|
+
help for details\.
|
30
|
+
.fi
|
31
|
+
.SH "EXAMPLES"
|
32
|
+
.nf
|
33
|
+
The following command deletes the preview with ID deployment\-213:
|
34
|
+
|
35
|
+
$ uffizzi preview delete deployment\-213
|
36
|
+
.fi
|
37
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
uffizzi preview delete - delete a preview
|
2
|
+
================================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
uffizzi preview delete [PREVIEW_ID] [UFFIZZI_WIDE_FLAG ...]
|
6
|
+
|
7
|
+
## DESCRIPTION
|
8
|
+
Deletes a preview with the given preview ID.
|
9
|
+
|
10
|
+
This command can fail for the following reasons:
|
11
|
+
- The preview specified does not exist.
|
12
|
+
- The preview specified belongs to a different project.
|
13
|
+
|
14
|
+
For more information on Uffizzi previews, see:
|
15
|
+
https://docs.uffizzi.com/cli/preview
|
16
|
+
|
17
|
+
## POSITIONAL ARGUMENTS
|
18
|
+
[PREVIEW_ID]
|
19
|
+
ID for the preview you want to delete.
|
20
|
+
|
21
|
+
## UFFIZZI WIDE FLAGS
|
22
|
+
These flags are available to all commands: --project. Run $ uffizzi
|
23
|
+
help for details.
|
24
|
+
|
25
|
+
## EXAMPLES
|
26
|
+
The following command deletes the preview with ID deployment-213:
|
27
|
+
|
28
|
+
$ uffizzi preview delete deployment-213
|
@@ -0,0 +1,38 @@
|
|
1
|
+
.\" generated with Ronn-NG/v0.9.1
|
2
|
+
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
3
|
+
.TH "DESCRIBE" "" "February 2022" ""
|
4
|
+
.SH "NAME"
|
5
|
+
\fBdescribe\fR \- show metadata for a preview
|
6
|
+
.SH "SYNOPSIS"
|
7
|
+
.nf
|
8
|
+
uffizzi preview describe [PREVIEW_ID] [UFFIZZI_WIDE_FLAG \|\.\|\.\|\.]
|
9
|
+
.fi
|
10
|
+
.SH "DESCRIPTION"
|
11
|
+
.nf
|
12
|
+
Shows metadata for a project given a valid preview ID\.
|
13
|
+
|
14
|
+
This command can fail for the following reasons:
|
15
|
+
\- The preview specified does not exist\.
|
16
|
+
\- The preview specified belongs to a different project\.
|
17
|
+
|
18
|
+
For more information on Uffizzi previews, see:
|
19
|
+
https://docs\.uffizzi\.com/cli/preview
|
20
|
+
.fi
|
21
|
+
.SH "POSITIONAL ARGUMENTS"
|
22
|
+
.nf
|
23
|
+
[PREVIEW_ID]
|
24
|
+
ID for the preview you want to describe\.
|
25
|
+
.fi
|
26
|
+
.SH "UFFIZZI WIDE FLAGS"
|
27
|
+
.nf
|
28
|
+
These flags are available to all commands: \-\-project\. Run $ uffizzi
|
29
|
+
help for details\.
|
30
|
+
.fi
|
31
|
+
.SH "EXAMPLES"
|
32
|
+
.nf
|
33
|
+
The following command prints metadata for the preview with ID
|
34
|
+
deployment\-213:
|
35
|
+
|
36
|
+
$ uffizzi preview describe deployment\-213
|
37
|
+
.fi
|
38
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
uffizzi preview describe - show metadata for a preview
|
2
|
+
================================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
uffizzi preview describe [PREVIEW_ID] [UFFIZZI_WIDE_FLAG ...]
|
6
|
+
|
7
|
+
## DESCRIPTION
|
8
|
+
Shows metadata for a project given a valid preview ID.
|
9
|
+
|
10
|
+
This command can fail for the following reasons:
|
11
|
+
- The preview specified does not exist.
|
12
|
+
- The preview specified belongs to a different project.
|
13
|
+
|
14
|
+
For more information on Uffizzi previews, see:
|
15
|
+
https://docs.uffizzi.com/cli/preview
|
16
|
+
|
17
|
+
## POSITIONAL ARGUMENTS
|
18
|
+
[PREVIEW_ID]
|
19
|
+
ID for the preview you want to describe.
|
20
|
+
|
21
|
+
## UFFIZZI WIDE FLAGS
|
22
|
+
These flags are available to all commands: --project. Run $ uffizzi
|
23
|
+
help for details.
|
24
|
+
|
25
|
+
## EXAMPLES
|
26
|
+
The following command prints metadata for the preview with ID
|
27
|
+
deployment-213:
|
28
|
+
|
29
|
+
$ uffizzi preview describe deployment-213
|
data/man/uffizzi-list
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
.\" generated with Ronn-NG/v0.9.1
|
2
|
+
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
3
|
+
.TH "LIST" "" "February 2022" ""
|
4
|
+
.SH "NAME"
|
5
|
+
\fBuffizzi preview list\fR \- list previews in a project
|
6
|
+
.SH "SYNOPSIS"
|
7
|
+
.nf
|
8
|
+
uffizzi preview list [UFFIZZI_WIDE_FLAG \|\.\|\.\|\.]
|
9
|
+
.fi
|
10
|
+
.SH "DESCRIPTION"
|
11
|
+
.nf
|
12
|
+
Lists all previews for a project, including active, building,
|
13
|
+
deploying and failed previews\.
|
14
|
+
|
15
|
+
For more information on Uffizzi previews, see:
|
16
|
+
https://docs\.uffizzi\.com/cli/preview
|
17
|
+
.fi
|
18
|
+
.SH "UFFIZZI WIDE FLAGS"
|
19
|
+
.nf
|
20
|
+
These flags are available to all commands: \-\-project\. Run $ uffizzi
|
21
|
+
help for details\.
|
22
|
+
.fi
|
23
|
+
.SH "EXAMPLES"
|
24
|
+
.nf
|
25
|
+
To list all previews in the default project, run:
|
26
|
+
|
27
|
+
$ uffizzi preview list
|
28
|
+
|
29
|
+
To list all previews in a project with name my_project, run:
|
30
|
+
|
31
|
+
$ uffizzi preview list \-\-project="my_project"
|
32
|
+
.fi
|
33
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
uffizzi preview list - list previews in a project
|
2
|
+
================================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
uffizzi preview list [UFFIZZI_WIDE_FLAG ...]
|
6
|
+
|
7
|
+
## DESCRIPTION
|
8
|
+
Lists all previews for a project, including active, building,
|
9
|
+
deploying and failed previews.
|
10
|
+
|
11
|
+
For more information on Uffizzi previews, see:
|
12
|
+
https://docs.uffizzi.com/cli/preview
|
13
|
+
|
14
|
+
## UFFIZZI WIDE FLAGS
|
15
|
+
These flags are available to all commands: --project. Run $ uffizzi
|
16
|
+
help for details.
|
17
|
+
|
18
|
+
## EXAMPLES
|
19
|
+
To list all previews in the default project, run:
|
20
|
+
|
21
|
+
$ uffizzi preview list
|
22
|
+
|
23
|
+
To list all previews in a project with name my_project, run:
|
24
|
+
|
25
|
+
$ uffizzi preview list --project="my_project"
|
data/man/uffizzi-preview
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
.\" generated with Ronn-NG/v0.9.1
|
2
|
+
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
3
|
+
.TH "PREVIEW" "" "February 2022" ""
|
4
|
+
.SH "NAME"
|
5
|
+
\fBpreview\fR \- manage previews
|
6
|
+
.SH "SYNOPSIS"
|
7
|
+
.nf
|
8
|
+
uffizzi preview COMMAND [UFFIZZI_WIDE_FLAG \|\.\|\.\|\.]
|
9
|
+
.fi
|
10
|
+
.SH "DESCRIPTION"
|
11
|
+
.nf
|
12
|
+
Manage Uffizzi previews
|
13
|
+
|
14
|
+
For more information on Uffizzi previews, see:
|
15
|
+
https://docs\.uffizzi\.com/cli/preview
|
16
|
+
.fi
|
17
|
+
.SH "UFFIZZI WIDE FLAGS"
|
18
|
+
.nf
|
19
|
+
These flags are available to all commands: \-\-project\. Run $ uffizzi
|
20
|
+
help for details\.
|
21
|
+
.fi
|
22
|
+
.SH "COMMANDS"
|
23
|
+
.nf
|
24
|
+
COMMAND is one of the following:
|
25
|
+
|
26
|
+
create
|
27
|
+
Create a preview
|
28
|
+
|
29
|
+
delete
|
30
|
+
Delete a preview
|
31
|
+
|
32
|
+
describe
|
33
|
+
Display details of a preview
|
34
|
+
|
35
|
+
list
|
36
|
+
List all previews
|
37
|
+
.fi
|
38
|
+
.SH "Run \'uffizzi preview COMMAND \-\-help\' for more information on a command\."
|
39
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
uffizzi preview - manage previews
|
2
|
+
================================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
uffizzi preview COMMAND [UFFIZZI_WIDE_FLAG ...]
|
6
|
+
|
7
|
+
## DESCRIPTION
|
8
|
+
Manage Uffizzi previews
|
9
|
+
|
10
|
+
For more information on Uffizzi previews, see:
|
11
|
+
https://docs.uffizzi.com/cli/preview
|
12
|
+
|
13
|
+
## UFFIZZI WIDE FLAGS
|
14
|
+
These flags are available to all commands: --project. Run $ uffizzi
|
15
|
+
help for details.
|
16
|
+
|
17
|
+
## COMMANDS
|
18
|
+
COMMAND is one of the following:
|
19
|
+
|
20
|
+
create
|
21
|
+
Create a preview
|
22
|
+
|
23
|
+
delete
|
24
|
+
Delete a preview
|
25
|
+
|
26
|
+
describe
|
27
|
+
Display details of a preview
|
28
|
+
|
29
|
+
list
|
30
|
+
List all previews
|
31
|
+
|
32
|
+
##
|
33
|
+
Run 'uffizzi preview COMMAND --help' for more information on a command.
|
data/uffizzi.gemspec
CHANGED
@@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_development_dependency 'rubocop'
|
42
42
|
spec.add_development_dependency 'rubocop-minitest'
|
43
43
|
spec.add_development_dependency 'rubocop-rake'
|
44
|
+
spec.add_development_dependency 'tty-spinner'
|
44
45
|
spec.add_development_dependency 'webmock'
|
45
46
|
|
46
47
|
spec.add_dependency 'thor'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uffizzi-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Thurman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-03-
|
12
|
+
date: 2022-03-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -207,6 +207,20 @@ dependencies:
|
|
207
207
|
- - ">="
|
208
208
|
- !ruby/object:Gem::Version
|
209
209
|
version: '0'
|
210
|
+
- !ruby/object:Gem::Dependency
|
211
|
+
name: tty-spinner
|
212
|
+
requirement: !ruby/object:Gem::Requirement
|
213
|
+
requirements:
|
214
|
+
- - ">="
|
215
|
+
- !ruby/object:Gem::Version
|
216
|
+
version: '0'
|
217
|
+
type: :development
|
218
|
+
prerelease: false
|
219
|
+
version_requirements: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
210
224
|
- !ruby/object:Gem::Dependency
|
211
225
|
name: webmock
|
212
226
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,6 +268,7 @@ files:
|
|
254
268
|
- Rakefile
|
255
269
|
- bin/console
|
256
270
|
- bin/setup
|
271
|
+
- config/config.rb
|
257
272
|
- config/uffizzi.rb
|
258
273
|
- docker-compose.yml
|
259
274
|
- exe/uffizzi
|
@@ -264,16 +279,30 @@ files:
|
|
264
279
|
- lib/uffizzi/cli/config.rb
|
265
280
|
- lib/uffizzi/cli/login.rb
|
266
281
|
- lib/uffizzi/cli/logout.rb
|
267
|
-
- lib/uffizzi/cli/
|
282
|
+
- lib/uffizzi/cli/preview.rb
|
283
|
+
- lib/uffizzi/cli/project.rb
|
284
|
+
- lib/uffizzi/cli/project/compose.rb
|
268
285
|
- lib/uffizzi/clients/api/api_client.rb
|
269
286
|
- lib/uffizzi/clients/api/api_routes.rb
|
270
287
|
- lib/uffizzi/clients/api/http_client.rb
|
271
288
|
- lib/uffizzi/config_file.rb
|
272
289
|
- lib/uffizzi/response_helper.rb
|
290
|
+
- lib/uffizzi/services/compose_file_service.rb
|
291
|
+
- lib/uffizzi/services/env_variables_service.rb
|
273
292
|
- lib/uffizzi/shell.rb
|
274
293
|
- lib/uffizzi/version.rb
|
294
|
+
- man/uffizzi-create
|
295
|
+
- man/uffizzi-create.ronn
|
296
|
+
- man/uffizzi-delete
|
297
|
+
- man/uffizzi-delete.ronn
|
298
|
+
- man/uffizzi-describe
|
299
|
+
- man/uffizzi-describe.ronn
|
300
|
+
- man/uffizzi-list
|
301
|
+
- man/uffizzi-list.ronn
|
275
302
|
- man/uffizzi-logout
|
276
303
|
- man/uffizzi-logout.ronn
|
304
|
+
- man/uffizzi-preview
|
305
|
+
- man/uffizzi-preview.ronn
|
277
306
|
- uffizzi.gemspec
|
278
307
|
homepage: https://uffizzi.com
|
279
308
|
licenses:
|
data/lib/uffizzi/cli/projects.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'io/console'
|
4
|
-
require 'uffizzi'
|
5
|
-
require 'uffizzi/auth_helper'
|
6
|
-
|
7
|
-
module Uffizzi
|
8
|
-
class CLI::Projects
|
9
|
-
include ApiClient
|
10
|
-
|
11
|
-
def run
|
12
|
-
return 'You are not logged in' unless Uffizzi::AuthHelper.signed_in?
|
13
|
-
|
14
|
-
hostname = ConfigFile.read_option(:hostname)
|
15
|
-
response = fetch_projects(hostname)
|
16
|
-
|
17
|
-
if response[:code] == Net::HTTPOK
|
18
|
-
handle_succeed_response(response)
|
19
|
-
else
|
20
|
-
handle_failed_response(response)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def handle_failed_response(response)
|
27
|
-
ApiClient.print_errors(response[:body][:errors])
|
28
|
-
end
|
29
|
-
|
30
|
-
def handle_succeed_response(response)
|
31
|
-
projects = response[:body][:projects]
|
32
|
-
if projects.empty?
|
33
|
-
puts 'No projects related to this email'
|
34
|
-
return
|
35
|
-
end
|
36
|
-
if projects.size == 1
|
37
|
-
ConfigFile.write_option(:project, projects.first[:slug])
|
38
|
-
end
|
39
|
-
print_projects(projects)
|
40
|
-
end
|
41
|
-
|
42
|
-
def print_projects(projects)
|
43
|
-
projects.each do |project|
|
44
|
-
puts (project[:slug]).to_s
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|