consist 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/exe/consist +4 -0
- data/lib/consist/cli.rb +14 -0
- data/lib/consist/thor_ext.rb +69 -0
- data/lib/consist/version.rb +3 -0
- data/lib/consist.rb +5 -0
- metadata +70 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e285e2e22c69505b96cdcc412a1430980b546f593c38459bc3bb23ac768a93ef
|
4
|
+
data.tar.gz: e399764524c566160f4aa6581f6f3841957ae539ae509df8a20b221c26d4b352
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e312b31429f842b4d0814863584065d727705f131833eb0d4e676ff9db358f2f2295d9ef6392b835f87a3e95b49df00c0841d7795eb11a6c7813b26967263d9f
|
7
|
+
data.tar.gz: db984c5ae14d35af01d9c16b0ae9d6b88d4d171137971f37e1dc2af963552826748eb3c79656b0df044ec135752e34b510800b2eeefb5e7723d5d743c9fd6f31
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 John McDowall
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# consist
|
2
|
+
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/consist)](https://rubygems.org/gems/consist)
|
4
|
+
[![Gem Downloads](https://img.shields.io/gem/dt/consist)](https://www.ruby-toolbox.com/projects/consist)
|
5
|
+
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/johnmcdowall/consist/ci.yml)](https://github.com/johnmcdowall/consist/actions/workflows/ci.yml)
|
6
|
+
[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/johnmcdowall/consist)](https://codeclimate.com/github/johnmcdowall/consist)
|
7
|
+
|
8
|
+
TODO: Description of this gem goes here.
|
9
|
+
|
10
|
+
---
|
11
|
+
|
12
|
+
- [Quick start](#quick-start)
|
13
|
+
- [Support](#support)
|
14
|
+
- [License](#license)
|
15
|
+
- [Code of conduct](#code-of-conduct)
|
16
|
+
- [Contribution guide](#contribution-guide)
|
17
|
+
|
18
|
+
## Quick start
|
19
|
+
|
20
|
+
```
|
21
|
+
gem install consist
|
22
|
+
```
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
require "consist"
|
26
|
+
```
|
27
|
+
|
28
|
+
## Support
|
29
|
+
|
30
|
+
If you want to report a bug, or have ideas, feedback or questions about the gem, [let me know via GitHub issues](https://github.com/johnmcdowall/consist/issues/new) and I will do my best to provide a helpful answer. Happy hacking!
|
31
|
+
|
32
|
+
## License
|
33
|
+
|
34
|
+
The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
|
35
|
+
|
36
|
+
## Code of conduct
|
37
|
+
|
38
|
+
Everyone interacting in this project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
|
39
|
+
|
40
|
+
## Contribution guide
|
41
|
+
|
42
|
+
Pull requests are welcome!
|
data/exe/consist
ADDED
data/lib/consist/cli.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
module Consist
|
4
|
+
class CLI < Thor
|
5
|
+
extend ThorExt::Start
|
6
|
+
|
7
|
+
map %w[-v --version] => "version"
|
8
|
+
|
9
|
+
desc "version", "Display consist version", hide: true
|
10
|
+
def version
|
11
|
+
say "consist/#{VERSION} #{RUBY_DESCRIPTION}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Consist
|
2
|
+
module ThorExt
|
3
|
+
# Configures Thor to behave more like a typical CLI, with better help and error handling.
|
4
|
+
#
|
5
|
+
# - Passing -h or --help to a command will show help for that command.
|
6
|
+
# - Unrecognized options will be treated as errors (instead of being silently ignored).
|
7
|
+
# - Error messages will be printed in red to stderr, without stack trace.
|
8
|
+
# - Full stack traces can be enabled by setting the VERBOSE environment variable.
|
9
|
+
# - Errors will cause Thor to exit with a non-zero status.
|
10
|
+
#
|
11
|
+
# To take advantage of this behavior, your CLI should subclass Thor and extend this module.
|
12
|
+
#
|
13
|
+
# class CLI < Thor
|
14
|
+
# extend ThorExt::Start
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# Start your CLI with:
|
18
|
+
#
|
19
|
+
# CLI.start
|
20
|
+
#
|
21
|
+
# In tests, prevent Kernel.exit from being called when an error occurs, like this:
|
22
|
+
#
|
23
|
+
# CLI.start(args, exit_on_failure: false)
|
24
|
+
#
|
25
|
+
module Start
|
26
|
+
def self.extended(base)
|
27
|
+
super
|
28
|
+
base.check_unknown_options!
|
29
|
+
end
|
30
|
+
|
31
|
+
def start(given_args=ARGV, config={})
|
32
|
+
config[:shell] ||= Thor::Base.shell.new
|
33
|
+
handle_help_switches(given_args) do |args|
|
34
|
+
dispatch(nil, args, nil, config)
|
35
|
+
end
|
36
|
+
rescue StandardError => e
|
37
|
+
handle_exception_on_start(e, config)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def handle_help_switches(given_args)
|
43
|
+
yield(given_args.dup)
|
44
|
+
rescue Thor::UnknownArgumentError => e
|
45
|
+
retry_with_args = []
|
46
|
+
|
47
|
+
if given_args.first == "help"
|
48
|
+
retry_with_args = ["help"] if given_args.length > 1
|
49
|
+
elsif (e.unknown & %w[-h --help]).any?
|
50
|
+
retry_with_args = ["help", (given_args - e.unknown).first]
|
51
|
+
end
|
52
|
+
raise unless retry_with_args.any?
|
53
|
+
|
54
|
+
yield(retry_with_args)
|
55
|
+
end
|
56
|
+
|
57
|
+
def handle_exception_on_start(error, config)
|
58
|
+
return if error.is_a?(Errno::EPIPE)
|
59
|
+
raise if ENV["VERBOSE"] || !config.fetch(:exit_on_failure, true)
|
60
|
+
|
61
|
+
message = error.message.to_s
|
62
|
+
message.prepend("[#{error.class}] ") if message.empty? || !error.is_a?(Thor::Error)
|
63
|
+
|
64
|
+
config[:shell]&.say_error(message, :red)
|
65
|
+
exit(false)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/consist.rb
ADDED
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: consist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John McDowall
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.2'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- j@jmd.fm
|
30
|
+
executables:
|
31
|
+
- consist
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- LICENSE.txt
|
36
|
+
- README.md
|
37
|
+
- exe/consist
|
38
|
+
- lib/consist.rb
|
39
|
+
- lib/consist/cli.rb
|
40
|
+
- lib/consist/thor_ext.rb
|
41
|
+
- lib/consist/version.rb
|
42
|
+
homepage: https://github.com/johnmcdowall/consist
|
43
|
+
licenses:
|
44
|
+
- MIT
|
45
|
+
metadata:
|
46
|
+
bug_tracker_uri: https://github.com/johnmcdowall/consist/issues
|
47
|
+
changelog_uri: https://github.com/johnmcdowall/consist/releases
|
48
|
+
source_code_uri: https://github.com/johnmcdowall/consist
|
49
|
+
homepage_uri: https://github.com/johnmcdowall/consist
|
50
|
+
rubygems_mfa_required: 'true'
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '3.0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubygems_version: 3.4.21
|
67
|
+
signing_key:
|
68
|
+
specification_version: 4
|
69
|
+
summary: The one person framework server scaffolder
|
70
|
+
test_files: []
|