Skip to content

Commit ad90dff

Browse files
committed
fix: Update CLI
1 parent 3e150f4 commit ad90dff

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

skyetel/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ See [examples](https://github.com/somleng/somleng-integrations/tree/develop/skye
2626
The CLI can be used to test your integration or in standalone mode.
2727

2828
```bash
29-
./bin/somleng-skyetel
29+
Usage: somleng-skyetel [options]
30+
--[no-]dry-run [FLAG] Dry run only. No phone numbers will be actually purchased.
31+
--[no-]verbose [FLAG] Run verbosely
32+
-h, --help Prints this help
3033
```
3134

3235
## Deployment

skyetel/bin/somleng-skyetel

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
require "bundler/setup"
55
require "optparse"
66
require_relative "../config/application"
7+
require "pry"
78

89
class OptionsParser
910
class MissingArgumentError < StandardError; end
1011

11-
Options = Struct.new(:dry_run, :verbose)
12+
Options = Struct.new(:dry_run, :verbose, :help)
1213

1314
attr_reader :parser, :options
1415

@@ -19,6 +20,8 @@ class OptionsParser
1920

2021
def parse
2122
parser.parse!
23+
return options if options.help
24+
2225
check_environment!("APP_ENV", "SOMLENG_API_KEY", "SKYETEL_USERNAME", "SKYETEL_PASSWORD", "MIN_STOCK", "MAX_STOCK")
2326
options
2427
end
@@ -40,13 +43,19 @@ class OptionsParser
4043
opts.banner = "Usage: somleng-skyetel [options]"
4144
opts.on("--[no-]dry-run [FLAG]", "Dry run only. No phone numbers will be actually purchased.", TrueClass) { |o| options.dry_run = o.nil? ? true : o }
4245
opts.on("--[no-]verbose [FLAG]", "Run verbosely", TrueClass) { |o| options.verbose = o.nil? ? true : o }
46+
opts.on("-h", "--help", "Prints this help", TrueClass) { |o| options.help = o.nil? ? true : o }
4347
end
4448
end
4549
end
4650

4751
def parse_options
4852
parser = OptionsParser.new
49-
parser.parse
53+
options = parser.parse
54+
if options.help
55+
puts parser.help
56+
exit(0)
57+
end
58+
options
5059
rescue OptionsParser::MissingArgumentError => e
5160
puts e.message
5261
puts parser.help

skyetel/examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The image is ready to be deployed to AWS Lambda and can be triggered by a schedu
1414

1515
## Standalone mode
1616

17-
If you're not using Lambda, you can run your image with the following command.
17+
If you're not using Lambda, you can run your image with the following command:
1818

1919
```bash
2020
docker run --platform linux/amd64 --rm -it -e APP_ENV=production -e SOMLENG_API_KEY='somleng-carrier-api-key' SOMLENG_API_KEY='somleng-carrier-api-key' -e SKYETEL_USERNAME='skyetel-username' -e SKYETEL_PASSWORD='skyetel-password' -e MIN_STOCK=5 -e MAX_STOCK=10 --entrypoint ./bin/somleng-skyetel somleng-skyetel:example

0 commit comments

Comments
 (0)