clik 0.1.0 → 0.2.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 24f9088c402a61dd7b972581fcb4356a40690889d064d9c91a01d739d3229cfa
4
+ data.tar.gz: b1d26d44b22de4f8b9e601a21c9a01f41ae8d8924bf9099373acf8091085605b
5
+ SHA512:
6
+ metadata.gz: 05ba3e41f0ed8c5f409880a1a885b4935528a2cd395dd24c168f88b1fa521a548253f2a709a7ebe1c6b2112c7b3ca2debf0f05ebda538990f9bbec0a72af340b
7
+ data.tar.gz: a33bf5421d11d01a2467fa5bf4d37c7bdcb360e0fbf9566f17a2065b36108c70ea6ad84fd7463c16b7c484ce7aa98bcf11c24e24ac457aeed1af3004f897ce8e
data/HISTORY.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # RELEASE HISTORY
2
2
 
3
+ ## 0.2.0 / 2026-04-09
4
+
5
+ Maintenance release modernizing the project.
6
+
7
+ Changes:
8
+
9
+ * Replace Indexer metadata with standard gemspec.
10
+ * Add Rakefile and minitest test suite.
11
+ * Rewrite README to clearly document what CLI.K adds to Clap.
12
+ * Add GitHub Actions CI (Ruby 3.1–3.4).
13
+ * Require Ruby >= 3.1.
14
+
15
+
3
16
  ## 0.1.0 / 2013-02-10
4
17
 
5
18
  This is this is the first release of CLI.K. Happy releaseday!
data/README.md CHANGED
@@ -1,83 +1,98 @@
1
1
  # CLI.K
2
2
 
3
- [Website](http://rubyworks.github.com/clik) /
4
- [Documentation](http://rubydoc.info/gems/clik/frames) /
5
- [Report Issue](http://github.com/rubyworks/clik/issues) /
6
- [Source Code](http://github.com/rubyworks/clik)    
7
- [![Build Status](https://travis-ci.org/rubyworks/clik.png)](https://travis-ci.org/rubyworks/clik)
8
- [![Gem Version](https://badge.fury.io/rb/clik.png)](http://badge.fury.io/rb/clik)
3
+ [Source Code](https://github.com/rubyworks/clik) |
4
+ [Report Issue](https://github.com/rubyworks/clik/issues)
9
5
 
6
+ [![Gem Version](https://img.shields.io/gem/v/clik.svg?style=flat)](https://rubygems.org/gems/clik)
10
7
 
11
- ## About
12
-
13
- CLI.K stands for Command Line Interface in the Kernel. It provides a very
14
- simple `cli` method for parsing command line options.
8
+ CLI.K stands for **Command Line Interface in the Kernel**. It is a tiny
9
+ command-line option parser exposed as a single Kernel method, `cli`,
10
+ which maps option strings to lambdas. There is no DSL, no help-text
11
+ machinery, and no auto-generated usage. The whole library is well under
12
+ 100 lines of code.
15
13
 
16
14
 
17
15
  ## Usage
18
16
 
19
- ### They call it "K.I.S.S."
17
+ ```ruby
18
+ require 'clik'
20
19
 
21
- Usage is very straightforward, although it might look a little odd at first
22
- glance:
20
+ cli '-f --file' => lambda { |f| @file = f },
21
+ '-d --debug' => lambda { $DEBUG = true },
22
+ '-h --help' => lambda { show_help }
23
+ ```
23
24
 
24
- ```ruby
25
- require 'clik'
25
+ Each key is an option (or a whitespace-separated list of aliases) and
26
+ each value is a lambda. The lambda's arity determines how many arguments
27
+ the option consumes from the command line.
28
+
29
+ By default `cli` reads from `ARGV`, but you can hand it any array as the
30
+ first argument:
26
31
 
27
- cli '-f --file' => lambda{ |f| @file = f },
28
- '-d --debug' => lambda{ $DEBUG = true },
29
- '-h --help' => lambda{ show_help }
32
+ ```ruby
33
+ cli ['--file', 'hello.txt'],
34
+ '-f --file' => lambda { |f| @file = f }
30
35
  ```
31
36
 
32
- There's very little to it really. The `cli` command simply maps command
33
- line options to procedures which are used to process them. That's it.
37
+ It returns whatever non-flag arguments were left over.
38
+
39
+ ### Bundled Short Flags
40
+
41
+ CLI.K expands run-on short flags the way standard Unix tools do:
42
+
43
+ ```ruby
44
+ # -abc is the same as -a -b -c
45
+ cli ['-abc'],
46
+ '-a' => lambda { ... },
47
+ '-b' => lambda { ... },
48
+ '-c' => lambda { ... }
49
+ ```
34
50
 
35
- In our example, notice that `-w` and `--whatever` are easily defined as
36
- synonymous options. Simple. Then notice that the `-f/--file` option's
37
- procedure takes an argument, so the command line option takes an argument
38
- as well. Again simple.
51
+ ### Asking the User Things
39
52
 
40
- The cli method has a few additional niceties. It can handle run-on flags,
41
- i.e. `-abc` is the same as `-a -b -c`. And you can pass it an alternate
42
- set of arguments to parse, as the first argument, to use something other
43
- than the default `ARGV`.
53
+ CLI.K also ships a tiny `ask` helper for prompting:
44
54
 
45
55
  ```ruby
46
- argv = ['--testing']
56
+ require 'clik/ask'
47
57
 
48
- cli argv,
49
- ...
58
+ ans = ask "Are you nice? [Y/n] ", "Y"
50
59
  ```
51
60
 
52
- ### You need help, no you really don't
61
+ ## Lineage and What CLI.K Adds to Clap
53
62
 
54
- At this point, you might be wonder about help output. Clearly there are
55
- no descriptions given in our example. Well, guess what! It's really easy
56
- to print something out yourself. In fact, if you really want to *do it right*,
57
- create a manpage with [ronn](git://github.com/rtomayko/ronn.git) or
58
- [md2man](https://github.com/sunaku/md2man), and impress your friends.
59
- It's a much better approach then jamming all that verbiage into you command
60
- line options parser code.
63
+ CLI.K is a direct descendant of [Clap](https://github.com/soveran/clap)
64
+ by Michel Martens, and the core option-dispatch loop is essentially
65
+ copied from it. Michel deserves the credit for the central insight that
66
+ this level of simplicity is all most command-line tools really need.
61
67
 
62
- ### Ask and you shell receive
68
+ What CLI.K adds on top of Clap:
63
69
 
64
- In addition to `cli` CLI.K include the `ask` method. This is a very simple
65
- command line query method.
70
+ | Feature | Clap | CLI.K |
71
+ |------------------------------------------------------|:----:|:-----:|
72
+ | Core option-to-lambda dispatch | ✓ | ✓ |
73
+ | Class-based API (`Clap.run(argv, opts)`) | ✓ | |
74
+ | Kernel method (`cli ...`) — no instantiation | | ✓ |
75
+ | Aliases packed into one key (`'-f --file' => ...`) | | ✓ |
76
+ | Bundled short flags (`-abc` → `-a -b -c`) | | ✓ |
77
+ | `ask` helper for interactive prompts | | ✓ |
66
78
 
67
- ans = ask "Are you nice? [Y/N]"
79
+ If you want a class-based, minimal-no-extras parser, use Clap. If you
80
+ want option aliases packed into the key and Unix-style short-flag
81
+ bundling exposed via a Kernel method, use CLI.K. They are conceptually
82
+ the same library with different ergonomic choices.
68
83
 
69
- Other Ruby libraries have their own take on the #ask method, and this very
70
- simple implementation can just as soon be overridden. No biggy. But it's nice
71
- to have for simple use cases.
72
84
 
85
+ ## Installation
73
86
 
74
- ## Acknowledgments
87
+ ```
88
+ $ gem install clik
89
+ ```
75
90
 
76
- We have to give credit where credit is due. This interface is the great
77
- achievement of Michel Martens, who created the original [Clap](https://github.com/soveran/clap)
78
- library from which CLI.K evolved. Mr. Martens deserves high praise for this
79
- design. It's not easy to realize that this level of simplicity is all one
80
- really needs! Thank you, Michel!
91
+ Or in a `Gemfile`:
92
+
93
+ ```ruby
94
+ gem 'clik'
95
+ ```
81
96
 
82
97
 
83
98
  ## Copyrights & License
@@ -85,9 +100,7 @@ really needs! Thank you, Michel!
85
100
  CLI.K is copyrighted open-source software.
86
101
 
87
102
  Copyright (c) 2013 Rubyworks
88
-
89
- CLI.K is base on Michel Marten's Clap library.
90
-
91
103
  Copyright (c) 2010 Michel Martens
92
104
 
93
- See LICENSE.txt and NOTICE.txt files for details.
105
+ Distributed under the **BSD-2-Clause** license.
106
+ See LICENSE.txt and NOTICE.txt for details.
data/lib/clik/ask.rb ADDED
@@ -0,0 +1,33 @@
1
+ module Kernel
2
+
3
+ module_function
4
+
5
+ # Very simple convenience method to get user input
6
+ # via the console. A prompt will be sent to $stdout,
7
+ # if given, and the input taken from $stdin...
8
+ #
9
+ # ask "Are you happy? [Yn]", "Y"
10
+ #
11
+ # On the command line one would see...
12
+ #
13
+ # Are you happy? [Yn]
14
+ #
15
+ # Responding...
16
+ #
17
+ # Are you happy? [Yn] Y <ENTER>
18
+ #
19
+ # The ask method would return "Y".
20
+ #
21
+ # Returns [String]
22
+ def ask(prompt=nil, default_answer=nil)
23
+ $stdout << "#{prompt}"
24
+ $stdout.flush
25
+ ans = $stdin.gets.chomp!
26
+ if ans == ''
27
+ default_answer
28
+ else
29
+ ans
30
+ end
31
+ end
32
+ end
33
+
data/lib/clik.yml ADDED
@@ -0,0 +1 @@
1
+ ../.index
metadata CHANGED
@@ -1,125 +1,77 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Trans
9
- autorequire:
8
+ - Michel Martens
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: detroit
14
+ name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '13'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '13'
30
27
  - !ruby/object:Gem::Dependency
31
- name: ergo
28
+ name: minitest
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '5'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: qed
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: ae
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- description: ! "CLI.K stands for Command Line Interface in the Kernel. It provides
79
- a very \nsimple `cli` method for parsing command line options."
40
+ version: '5'
41
+ description: CLI.K is a tiny command-line option parser based on Michel Martens' Clap,
42
+ exposed as a Kernel method with support for option aliases and bundled short flags.
80
43
  email:
81
44
  - transfire@gmail.com
82
45
  executables: []
83
46
  extensions: []
84
- extra_rdoc_files:
47
+ extra_rdoc_files: []
48
+ files:
49
+ - HISTORY.md
85
50
  - LICENSE.txt
86
51
  - NOTICE.txt
87
- - HISTORY.md
88
52
  - README.md
89
- files:
90
- - .index
91
- - demo/applique/req.rb
92
- - demo/clik.md
93
- - lib/clik.yml
94
53
  - lib/clik.rb
95
- - LICENSE.txt
96
- - HISTORY.md
97
- - README.md
98
- - NOTICE.txt
99
- homepage: http://rubyworks.github.com/clik
54
+ - lib/clik.yml
55
+ - lib/clik/ask.rb
56
+ homepage: https://github.com/rubyworks/clik
100
57
  licenses:
101
58
  - BSD-2-Clause
102
- post_install_message:
59
+ metadata: {}
103
60
  rdoc_options: []
104
61
  require_paths:
105
62
  - lib
106
63
  required_ruby_version: !ruby/object:Gem::Requirement
107
- none: false
108
64
  requirements:
109
- - - ! '>='
65
+ - - ">="
110
66
  - !ruby/object:Gem::Version
111
- version: '0'
67
+ version: '3.1'
112
68
  required_rubygems_version: !ruby/object:Gem::Requirement
113
- none: false
114
69
  requirements:
115
- - - ! '>='
70
+ - - ">="
116
71
  - !ruby/object:Gem::Version
117
72
  version: '0'
118
73
  requirements: []
119
- rubyforge_project:
120
- rubygems_version: 1.8.24
121
- signing_key:
122
- specification_version: 3
123
- summary: Command-line Interface in the Kernel
74
+ rubygems_version: 3.6.9
75
+ specification_version: 4
76
+ summary: Command Line Interface in the Kernel
124
77
  test_files: []
125
- has_rdoc:
data/.index DELETED
@@ -1,69 +0,0 @@
1
- ---
2
- revision: 2013
3
- type: ruby
4
- sources:
5
- - var
6
- authors:
7
- - name: Trans
8
- email: transfire@gmail.com
9
- organizations:
10
- - name: Rubyworks
11
- requirements:
12
- - groups:
13
- - build
14
- development: true
15
- name: detroit
16
- - groups:
17
- - build
18
- development: true
19
- name: ergo
20
- - groups:
21
- - test
22
- development: true
23
- name: qed
24
- - groups:
25
- - test
26
- development: true
27
- name: ae
28
- conflicts: []
29
- alternatives: []
30
- resources:
31
- - type: home
32
- uri: http://rubyworks.github.com/clik
33
- label: Homepage
34
- - type: code
35
- uri: http://github.com/rubyworks/clik
36
- label: Source Code
37
- - type: docs
38
- uri: http://rubydoc.info/gems/clik
39
- label: Documentation
40
- - type: wiki
41
- uri: http://wiki.github.com/rubyworks/clik
42
- label: User Guide
43
- - type: bugs
44
- uri: http://github.com/rubyworks/clik/issues
45
- label: Issue Tracker
46
- - type: mail
47
- uri: http://groups.google.com/group/rubyworks-mailinglist
48
- label: Mailing List
49
- repositories:
50
- - name: upstream
51
- scm: git
52
- uri: git://github.com/rubyworks/clik.git
53
- categories: []
54
- copyrights:
55
- - holder: Rubyworks
56
- year: '2013'
57
- license: BSD-2-Clause
58
- customs: []
59
- paths:
60
- lib:
61
- - lib
62
- created: '2013-01-01'
63
- summary: Command-line Interface in the Kernel
64
- title: CLI.K
65
- version: 0.1.0
66
- name: clik
67
- description: ! "CLI.K stands for Command Line Interface in the Kernel. It provides
68
- a very \nsimple `cli` method for parsing command line options."
69
- date: '2013-03-07'
data/demo/applique/req.rb DELETED
@@ -1,2 +0,0 @@
1
- require 'ae'
2
- require 'clik'
data/demo/clik.md DELETED
@@ -1,25 +0,0 @@
1
- # CLI.K
2
-
3
- CLI.K provides a kernel method.
4
-
5
- opts = {}
6
- argv = ['-x']
7
-
8
- cli argv,
9
- '-x' => lambda{ opts[:x] = true }
10
-
11
- opts[:x].assert === true
12
-
13
- Another example,
14
-
15
- opts = {}
16
- argv = ['-w', '-f', 'hello']
17
-
18
- cli argv,
19
- '-w --whatever' => ->{ opts[:w] = true },
20
- '-f --file' => ->(f){ opts[:f] = f },
21
- '-h --help' => ->{ puts "help" }
22
-
23
- opts[:w].assert == true
24
- opts[:f].assert == 'hello'
25
-
data/lib/clik.yml DELETED
@@ -1,69 +0,0 @@
1
- ---
2
- revision: 2013
3
- type: ruby
4
- sources:
5
- - var
6
- authors:
7
- - name: Trans
8
- email: transfire@gmail.com
9
- organizations:
10
- - name: Rubyworks
11
- requirements:
12
- - groups:
13
- - build
14
- development: true
15
- name: detroit
16
- - groups:
17
- - build
18
- development: true
19
- name: ergo
20
- - groups:
21
- - test
22
- development: true
23
- name: qed
24
- - groups:
25
- - test
26
- development: true
27
- name: ae
28
- conflicts: []
29
- alternatives: []
30
- resources:
31
- - type: home
32
- uri: http://rubyworks.github.com/clik
33
- label: Homepage
34
- - type: code
35
- uri: http://github.com/rubyworks/clik
36
- label: Source Code
37
- - type: docs
38
- uri: http://rubydoc.info/gems/clik
39
- label: Documentation
40
- - type: wiki
41
- uri: http://wiki.github.com/rubyworks/clik
42
- label: User Guide
43
- - type: bugs
44
- uri: http://github.com/rubyworks/clik/issues
45
- label: Issue Tracker
46
- - type: mail
47
- uri: http://groups.google.com/group/rubyworks-mailinglist
48
- label: Mailing List
49
- repositories:
50
- - name: upstream
51
- scm: git
52
- uri: git://github.com/rubyworks/clik.git
53
- categories: []
54
- copyrights:
55
- - holder: Rubyworks
56
- year: '2013'
57
- license: BSD-2-Clause
58
- customs: []
59
- paths:
60
- lib:
61
- - lib
62
- created: '2013-01-01'
63
- summary: Command-line Interface in the Kernel
64
- title: CLI.K
65
- version: 0.1.0
66
- name: clik
67
- description: ! "CLI.K stands for Command Line Interface in the Kernel. It provides
68
- a very \nsimple `cli` method for parsing command line options."
69
- date: '2013-03-07'