Skip to content

Commit

Permalink
fix: Update CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Oct 12, 2024
1 parent 3e150f4 commit ad90dff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
5 changes: 4 additions & 1 deletion skyetel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ See [examples](https://github.com/somleng/somleng-integrations/tree/develop/skye
The CLI can be used to test your integration or in standalone mode.

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

## Deployment
Expand Down
13 changes: 11 additions & 2 deletions skyetel/bin/somleng-skyetel
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
require "bundler/setup"
require "optparse"
require_relative "../config/application"
require "pry"

class OptionsParser
class MissingArgumentError < StandardError; end

Options = Struct.new(:dry_run, :verbose)
Options = Struct.new(:dry_run, :verbose, :help)

attr_reader :parser, :options

Expand All @@ -19,6 +20,8 @@ class OptionsParser

def parse
parser.parse!
return options if options.help

check_environment!("APP_ENV", "SOMLENG_API_KEY", "SKYETEL_USERNAME", "SKYETEL_PASSWORD", "MIN_STOCK", "MAX_STOCK")
options
end
Expand All @@ -40,13 +43,19 @@ class OptionsParser
opts.banner = "Usage: somleng-skyetel [options]"
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 }
opts.on("--[no-]verbose [FLAG]", "Run verbosely", TrueClass) { |o| options.verbose = o.nil? ? true : o }
opts.on("-h", "--help", "Prints this help", TrueClass) { |o| options.help = o.nil? ? true : o }
end
end
end

def parse_options
parser = OptionsParser.new
parser.parse
options = parser.parse
if options.help
puts parser.help
exit(0)
end
options
rescue OptionsParser::MissingArgumentError => e
puts e.message
puts parser.help
Expand Down
2 changes: 1 addition & 1 deletion skyetel/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The image is ready to be deployed to AWS Lambda and can be triggered by a schedu

## Standalone mode

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

```bash
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
Expand Down

0 comments on commit ad90dff

Please sign in to comment.