bootic_cli 0.1.0 → 0.1.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: 5f2a3c068eab8692e48632559045c3df977266d3
4
- data.tar.gz: 26ebde53b193412f58110f95bfd72e2cec736ace
3
+ metadata.gz: 1cf13197e1e1dc7d25ccba82f1d82163ce9f148f
4
+ data.tar.gz: 4716c8976aec0a34fa4c4b4efcb2e3cb56fadbcd
5
5
  SHA512:
6
- metadata.gz: 3f0ad5def58d8eaabdf3535aaf0cacc17d70fa401d45c39f280edc0f798737bcea68220bc51ba4e7229c684d0b3c5cfdbe9bb2e90101c273469e0ed93d273035
7
- data.tar.gz: ad5d228ff4e5b31eeb8696baef6744cf206919100f8582a0f7f04cf0285376415739f0ccefa42e885a137600dacabc0ce0865a8365d09fa246d5dd602db52bb4
6
+ metadata.gz: 253dc69ae10e863e15ab38f54ec701045b349ed8de7fefa1cf0faf3db8d4df9f2db8cfe74db60d78f8dbb44900b2011bcb4686ead781abc9c03907605080fbf4
7
+ data.tar.gz: c689a4cbe09eda6b6043ab6fa8595b668a747eace1f32caa00331a74a1ba8035af376c46adc5d2a6bbc7bebd836918db82bf2d4147545abf5afdc929f63d51eb
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Bootic CLI
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/btc`. To experiment with that code, run `bin/console` for an interactive prompt.
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/[my-github-username]/btc/fork )
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`)
@@ -27,7 +27,7 @@ module BooticCli
27
27
  invoke :setup, []
28
28
  end
29
29
 
30
- username = ask("Enter your Bootic user name:")
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
- require f
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
- require f
137
+ load_file f
130
138
  end
131
139
  end
132
140
  end
@@ -1,3 +1,3 @@
1
1
  module BooticCli
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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: 2016-12-08 00:00:00.000000000 Z
11
+ date: 2017-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor