zxc 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +24 -14
- data/bin/zxc +29 -0
- data/lib/zxc/version.rb +1 -1
- metadata +7 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f773e74ecf369e69253cdf0d61a98d05c88eea29dfe0e143830795ce687bae31
|
|
4
|
+
data.tar.gz: d273a757deb2e8a15cf8c2a1c8bca8a78b4d625d0ece31fb36466be0b92d943e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c760b9ecc6652389fdb27643bee1664e7668124d8934546ed63bf2744dc2555906737f0ac6f5afc748284a72a1ba62055a8ebe338bc9b5d4df9a295eda60f87
|
|
7
|
+
data.tar.gz: 9c99fc06e8404f667b0eda2bac11306a33826b976cc5e04aa0dc48f79574822af4d5171957d82360838d254e1311bb10682721975ed8a155e84eb4458dd00059
|
data/README.md
CHANGED
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
# Zxc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**zxc** allows you to quickly perform a few common opperations on STDIN, for example:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
```bash
|
|
6
|
+
echo $PATH | zxc split : split / present print
|
|
7
|
+
```
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
The command chain above will
|
|
10
|
+
1. get the list of directories in your `$PATH`,
|
|
11
|
+
2. split it into a list, using ":" as a delimiter,
|
|
12
|
+
3. split each element of said list into a sublist, using "/" as a delimiter,
|
|
13
|
+
4. remove empty elements,
|
|
14
|
+
5. print every element of every sublist.
|
|
15
|
+
|
|
16
|
+
This works by generating a tree, where each node contains text, and exposing "steps" to the user, which are procedures over said tree, In the example above, "split", "present" and "print" are steps, the first one taking arguments.
|
|
17
|
+
|
|
18
|
+
Use `zxc -H` to read a manual listing available steps.
|
|
8
19
|
|
|
9
|
-
|
|
20
|
+
## Installation
|
|
10
21
|
|
|
11
22
|
Install the gem and add to the application's Gemfile by executing:
|
|
12
23
|
|
|
13
24
|
```bash
|
|
14
|
-
bundle add
|
|
25
|
+
bundle add zxc
|
|
15
26
|
```
|
|
16
27
|
|
|
17
28
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
18
29
|
|
|
19
30
|
```bash
|
|
20
|
-
gem install
|
|
31
|
+
gem install zxc
|
|
21
32
|
```
|
|
22
33
|
|
|
23
34
|
## Usage
|
|
24
35
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
36
|
+
```bash
|
|
37
|
+
zxc [OPTIONS] [STEP [ARG]...]...
|
|
38
|
+
```
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
**zxc** reads text from STDIN, converts it into the root node of a tree, and applies operations (steps) onto said tree.
|
|
32
41
|
|
|
33
|
-
|
|
42
|
+
### Options
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
- **-h , --help**: Displays a short help message and exits
|
|
45
|
+
- **-H ", --Help**: Displays this page and exits
|
|
36
46
|
|
|
37
47
|
## License
|
|
38
48
|
|
data/bin/zxc
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
|
|
5
|
+
require_relative "../lib/zxc"
|
|
6
|
+
|
|
7
|
+
MAN_PAGE = File.join(__dir__,'..','man','zxc.1')
|
|
8
|
+
|
|
9
|
+
if %w[-h --help].include? ARGV[0]
|
|
10
|
+
puts <<~EOT.chomp
|
|
11
|
+
usage: zxc [options] [step [arg...]...]
|
|
12
|
+
\t-h,\t--help\t\tShow this help message
|
|
13
|
+
\t-H,\t--Help\t\tDisplay detailed help page
|
|
14
|
+
EOT
|
|
15
|
+
exit
|
|
16
|
+
elsif %w[-H --Help].include? ARGV[0]
|
|
17
|
+
system("man", MAN_PAGE)
|
|
18
|
+
exit
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
begin
|
|
22
|
+
Zxc::Zxc.new.run
|
|
23
|
+
rescue Zxc::UnknownStepError => e
|
|
24
|
+
STDERR.puts "Unknown step '#{e.meta[:step]}'."
|
|
25
|
+
rescue Zxc::WrongArgumentNumberError => e
|
|
26
|
+
STDERR.puts "At step '#{e.meta[:step]}': " \
|
|
27
|
+
"expected #{e.meta[:expected]} argument(s), " \
|
|
28
|
+
"but got #{e.meta[:actual]}."
|
|
29
|
+
end
|
data/lib/zxc/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,41 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zxc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- tiago-macedo
|
|
8
8
|
autorequire:
|
|
9
|
-
bindir:
|
|
9
|
+
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2025-07-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
|
-
description:
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
$ echo $PATH | zxc split : split / present print
|
|
17
|
-
```
|
|
18
|
-
The command chain above will
|
|
19
|
-
1. get the list of directories in your `$PATH`,
|
|
20
|
-
2. split it into a list, using ":" as a delimiter,
|
|
21
|
-
3. split each element of said list into a sublist, using "/" as a delimiter,
|
|
22
|
-
4. remove empty elements,
|
|
23
|
-
5. print every element of every sublist.
|
|
24
|
-
|
|
25
|
-
This works by generating a tree, where each node contains text, and exposing
|
|
26
|
-
"steps" to the user, which are procedures over said tree, In the example above,
|
|
27
|
-
"split", "present" and "print" are steps, the first one taking arguments.
|
|
28
|
-
|
|
29
|
-
Use `zxc -H` to read a manual listing available steps.
|
|
13
|
+
description: "`zxc` is a command line program that takes in text, turns it into a
|
|
14
|
+
tree, and exposes procedures to manipulate this tree."
|
|
30
15
|
email:
|
|
31
16
|
- tiagomacedo@ufrj.br
|
|
32
|
-
executables:
|
|
17
|
+
executables:
|
|
18
|
+
- zxc
|
|
33
19
|
extensions: []
|
|
34
20
|
extra_rdoc_files: []
|
|
35
21
|
files:
|
|
36
22
|
- LICENSE.txt
|
|
37
23
|
- README.md
|
|
38
24
|
- Rakefile
|
|
25
|
+
- bin/zxc
|
|
39
26
|
- lib/zxc.rb
|
|
40
27
|
- lib/zxc/error.rb
|
|
41
28
|
- lib/zxc/errors/unknown_step_error.rb
|