bootic_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.
- checksums.yaml +4 -4
- data/README.md +77 -4
- data/lib/bootic_cli/cli.rb +11 -3
- 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: 1cf13197e1e1dc7d25ccba82f1d82163ce9f148f
|
4
|
+
data.tar.gz: 4716c8976aec0a34fa4c4b4efcb2e3cb56fadbcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 253dc69ae10e863e15ab38f54ec701045b349ed8de7fefa1cf0faf3db8d4df9f2db8cfe74db60d78f8dbb44900b2011bcb4686ead781abc9c03907605080fbf4
|
7
|
+
data.tar.gz: c689a4cbe09eda6b6043ab6fa8595b668a747eace1f32caa00331a74a1ba8035af376c46adc5d2a6bbc7bebd836918db82bf2d4147545abf5afdc929f63d51eb
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Bootic CLI
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
CLI to interact with the [Bootic.net API](https://developers.bootic.net/) and run custom API scripts.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -20,6 +18,81 @@ btc login
|
|
20
18
|
btc console
|
21
19
|
```
|
22
20
|
|
21
|
+
### Console
|
22
|
+
|
23
|
+
`btc console` launches an API session into an IRB console. You'll have `root` and `shop` API entities already initialized for you.
|
24
|
+
|
25
|
+
```
|
26
|
+
shop.orders(status: "all").each do |o|
|
27
|
+
puts o.total
|
28
|
+
end
|
29
|
+
|
30
|
+
explain shop
|
31
|
+
|
32
|
+
list shop.products
|
33
|
+
|
34
|
+
explain_link shop, :products
|
35
|
+
```
|
36
|
+
|
37
|
+
### Custom scripts
|
38
|
+
|
39
|
+
You can run simple Ruby scripts in the context of an API session with
|
40
|
+
|
41
|
+
```
|
42
|
+
btc runner my_script.rb
|
43
|
+
```
|
44
|
+
|
45
|
+
Your script will be provided with the following variables
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# the API root resource
|
49
|
+
root
|
50
|
+
|
51
|
+
# your default shop
|
52
|
+
shop
|
53
|
+
```
|
54
|
+
|
55
|
+
An example script that lists your shop's products
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
# list_products.rb
|
59
|
+
shop.products.full_set.each do |pr|
|
60
|
+
puts pr.title
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
You run it with
|
65
|
+
|
66
|
+
```
|
67
|
+
btc runner list_products.rb
|
68
|
+
```
|
69
|
+
|
70
|
+
### Custom Thor commands
|
71
|
+
|
72
|
+
More advanced scripts can be written as [Thor]() commands. Any scripts in `~/btc` will be loaded automatically.
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
# ~/btc/list_products
|
76
|
+
class ListProducts < BooticCli::Command
|
77
|
+
desc "list", "list products by status"
|
78
|
+
option :s, banner: "<status>"
|
79
|
+
def list
|
80
|
+
shop.products(status: options["s"]).full_set.each do |pr|
|
81
|
+
puts pr.title
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
Now `btc help` will list your custom `list_products` command.
|
88
|
+
|
89
|
+
```
|
90
|
+
btc help list_products
|
91
|
+
|
92
|
+
# list hidden products
|
93
|
+
btc list_products list -s hidden
|
94
|
+
```
|
95
|
+
|
23
96
|
## Development
|
24
97
|
|
25
98
|
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 btc` to use the code located in this directory, ignoring other installed copies of this gem.
|
@@ -28,7 +101,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
28
101
|
|
29
102
|
## Contributing
|
30
103
|
|
31
|
-
1. Fork it ( https://github.com/
|
104
|
+
1. Fork it ( https://github.com/bootic/bootic_cli/fork )
|
32
105
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
106
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
107
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/bootic_cli/cli.rb
CHANGED
@@ -27,7 +27,7 @@ module BooticCli
|
|
27
27
|
invoke :setup, []
|
28
28
|
end
|
29
29
|
|
30
|
-
username = ask("Enter your Bootic
|
30
|
+
username = ask("Enter your Bootic email")
|
31
31
|
pwd = ask("Enter your Bootic password:", echo: false)
|
32
32
|
|
33
33
|
say "Loging in as #{username}. Getting access token..."
|
@@ -118,15 +118,23 @@ module BooticCli
|
|
118
118
|
downcase.split("/").last
|
119
119
|
end
|
120
120
|
|
121
|
+
def self.load_file(f)
|
122
|
+
begin
|
123
|
+
require f
|
124
|
+
rescue LoadError => e
|
125
|
+
puts "#{e.class} loading #{f}: #{e.message}"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
121
129
|
require "bootic_cli/command"
|
122
130
|
|
123
131
|
Dir[File.join(File.dirname(__FILE__), 'cli', '*.rb')].each do |f|
|
124
|
-
|
132
|
+
load_file f
|
125
133
|
end
|
126
134
|
|
127
135
|
if File.directory?(CUSTOM_COMMANDS_DIR)
|
128
136
|
Dir[File.join(CUSTOM_COMMANDS_DIR, '*.rb')].each do |f|
|
129
|
-
|
137
|
+
load_file f
|
130
138
|
end
|
131
139
|
end
|
132
140
|
end
|
data/lib/bootic_cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bootic_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ismael Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|