bootic_cli 0.2.1 → 0.3.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/README.md +32 -35
- data/Rakefile +2 -3
- data/lib/bootic_cli.rb +1 -1
- data/lib/bootic_cli/cli.rb +9 -9
- data/lib/bootic_cli/store.rb +1 -1
- data/lib/bootic_cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1635165613bb3c1108f62bcf3fb9a455b66a22cc
|
4
|
+
data.tar.gz: b9eda84070803bdf7892769033bc5ceb4dd38b05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2921db246029beec8a51e242a5635524a7106fc8f2d2cd93cd52b660597b4bee084ed04ef09109ee2502fce068be135a276f08d002fdbde761653d1d78fb5124
|
7
|
+
data.tar.gz: 07db650fb21e51a90e1042c940ada82a8af43abdb85f6a34a183caa391153bca54c6b045f4c248abfc4e8910171b9683fecfc55965dc6ad52f60cad3d732121b
|
data/README.md
CHANGED
@@ -6,50 +6,45 @@ CLI to interact with the [Bootic.net API](https://developers.bootic.net/) and ru
|
|
6
6
|
|
7
7
|
Install in your system.
|
8
8
|
|
9
|
-
|
10
|
-
gem install bootic_cli
|
11
|
-
```
|
9
|
+
gem install bootic_cli
|
12
10
|
|
13
11
|
## Usage
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
```
|
13
|
+
bootic help
|
14
|
+
bootic setup
|
15
|
+
bootic login
|
16
|
+
bootic console
|
20
17
|
|
21
18
|
### Console
|
22
19
|
|
23
|
-
`
|
20
|
+
`bootic console` launches an API session into an IRB console. You'll have `root` and `shop` API entities already initialized for you.
|
24
21
|
|
25
22
|
```
|
26
|
-
shop.orders(status: "all").each do |o|
|
27
|
-
|
28
|
-
end
|
23
|
+
> shop.orders(status: "all").each do |o|
|
24
|
+
> puts o.total
|
25
|
+
> end
|
29
26
|
|
30
|
-
explain shop
|
27
|
+
> explain shop
|
31
28
|
|
32
|
-
list shop.products
|
29
|
+
> list shop.products
|
33
30
|
|
34
|
-
explain_link shop, :products
|
31
|
+
> explain_link shop, :products
|
35
32
|
```
|
36
33
|
|
37
34
|
Access the configured client:
|
38
35
|
|
39
36
|
```
|
40
|
-
client session.client
|
41
|
-
new_root = client.from_url("https://some.endpoint.com")
|
37
|
+
> client session.client
|
38
|
+
> new_root = client.from_url("https://some.endpoint.com")
|
42
39
|
```
|
43
40
|
|
44
41
|
### Custom scripts
|
45
42
|
|
46
43
|
You can run simple Ruby scripts in the context of an API session with
|
47
44
|
|
48
|
-
|
49
|
-
btc runner my_script.rb
|
50
|
-
```
|
45
|
+
bootic runner my_script.rb
|
51
46
|
|
52
|
-
Your script will be provided with the following variables
|
47
|
+
Your script will be provided with the following variables:
|
53
48
|
|
54
49
|
```ruby
|
55
50
|
# the API root resource
|
@@ -59,50 +54,52 @@ root
|
|
59
54
|
shop
|
60
55
|
```
|
61
56
|
|
62
|
-
An example script that lists your shop's products
|
57
|
+
An example script that lists your shop's products:
|
63
58
|
|
64
59
|
```ruby
|
65
60
|
# list_products.rb
|
66
|
-
shop.products.full_set.each do |
|
67
|
-
puts
|
61
|
+
shop.products.full_set.each do |p|
|
62
|
+
puts p.title
|
68
63
|
end
|
69
64
|
```
|
70
65
|
|
71
|
-
You run it with
|
66
|
+
You run it with:
|
72
67
|
|
73
68
|
```
|
74
|
-
|
69
|
+
bootic runner list_products.rb
|
75
70
|
```
|
76
71
|
|
77
72
|
### Custom Thor commands
|
78
73
|
|
79
|
-
More advanced scripts can be written as [Thor]() commands. Any scripts in
|
74
|
+
More advanced scripts can be written as [Thor]() commands. Any scripts in `~/.bootic` will be loaded automatically.
|
80
75
|
|
81
76
|
```ruby
|
82
|
-
#
|
77
|
+
# ~/.bootic/list_products
|
83
78
|
class ListProducts < BooticCli::Command
|
79
|
+
|
84
80
|
desc "list", "list products by status"
|
85
81
|
option :s, banner: "<status>"
|
86
82
|
def list
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
shop.products(status: options["s"]).full_set.each do |p|
|
84
|
+
puts p.title
|
85
|
+
end
|
90
86
|
end
|
87
|
+
|
91
88
|
end
|
92
89
|
```
|
93
90
|
|
94
|
-
Now `
|
91
|
+
Now `bootic help` will list your custom `list_products` command.
|
95
92
|
|
96
93
|
```
|
97
|
-
|
94
|
+
bootic help list_products
|
98
95
|
|
99
96
|
# list hidden products
|
100
|
-
|
97
|
+
bootic list_products list -s hidden
|
101
98
|
```
|
102
99
|
|
103
100
|
## Development
|
104
101
|
|
105
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec
|
102
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec bootic` to use the code located in this directory, ignoring other installed copies of this gem.
|
106
103
|
|
107
104
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
108
105
|
|
data/Rakefile
CHANGED
data/lib/bootic_cli.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require 'bootic_cli/cli'
|
data/lib/bootic_cli/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module BooticCli
|
|
9
9
|
include Thor::Actions
|
10
10
|
include BooticCli::Connectivity
|
11
11
|
|
12
|
-
CUSTOM_COMMANDS_DIR = ENV.fetch(
|
12
|
+
CUSTOM_COMMANDS_DIR = ENV.fetch('BTC_CUSTOM_COMMANDS_PATH') { File.join(ENV['HOME'], 'bootic') }
|
13
13
|
|
14
14
|
# override Thor's help method to print banner and check for keys
|
15
15
|
def help
|
@@ -32,7 +32,7 @@ module BooticCli
|
|
32
32
|
if session.setup?
|
33
33
|
input = ask "Looks like you're already set up. Do you want to re-enter your app's credentials? [n]", :magenta
|
34
34
|
if input != 'y'
|
35
|
-
say 'Thought so.
|
35
|
+
say 'Thought so. You can run `bootic help` for a list of supported commands.'
|
36
36
|
exit(1)
|
37
37
|
end
|
38
38
|
else
|
@@ -85,24 +85,24 @@ module BooticCli
|
|
85
85
|
if session.logged_in?
|
86
86
|
input = ask "Looks like you're already logged in. Do you want to redo this step? [n]", :magenta
|
87
87
|
if input != 'y'
|
88
|
-
say '
|
88
|
+
say "That's what I thought! Try running `bootic help`."
|
89
89
|
exit(1)
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
|
94
|
-
|
93
|
+
email = ask("Enter your Bootic email:", :bold)
|
94
|
+
pass = ask("Enter your Bootic password:", :bold, echo: false)
|
95
95
|
|
96
|
-
if
|
96
|
+
if email.strip == '' or email['@'].nil? or pass.strip == ''
|
97
97
|
say "\nPlease make sure to enter valid data.", :red
|
98
98
|
exit 1
|
99
99
|
end
|
100
100
|
|
101
|
-
say "\n\nAlrighty! Getting access token for #{
|
101
|
+
say "\n\nAlrighty! Getting access token for #{email}...\n"
|
102
102
|
|
103
103
|
begin
|
104
|
-
session.login(
|
105
|
-
say "Great success! You're now logged in as #{
|
104
|
+
session.login(email, pass, scope)
|
105
|
+
say "Great success! You're now logged in as #{email} (#{scope})", :green
|
106
106
|
say "For a list of available commands, run `bootic help`."
|
107
107
|
rescue StandardError => e
|
108
108
|
say e.message, :red
|
data/lib/bootic_cli/store.rb
CHANGED
@@ -6,7 +6,7 @@ module BooticCli
|
|
6
6
|
class Store
|
7
7
|
VERSION = 1
|
8
8
|
DEFAULT_NAMESPACE = 'production'.freeze
|
9
|
-
DIRNAME
|
9
|
+
DIRNAME = '.bootic'.freeze
|
10
10
|
FILE_NAME = 'store.pstore'.freeze
|
11
11
|
|
12
12
|
def initialize(base_dir: ENV['HOME'], dir: DIRNAME, namespace: DEFAULT_NAMESPACE)
|
data/lib/bootic_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootic_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ismael Celis
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
version: '0'
|
199
199
|
requirements: []
|
200
200
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
201
|
+
rubygems_version: 2.5.1
|
202
202
|
signing_key:
|
203
203
|
specification_version: 4
|
204
204
|
summary: Bootic command-line client.
|