alf-shell 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +35 -0
- data/LICENCE.md +22 -0
- data/Manifest.txt +13 -0
- data/README.md +11 -0
- data/Rakefile +11 -0
- data/bin/alf +17 -0
- data/lib/alf-shell.rb +1 -0
- data/lib/alf/shell.rb +48 -0
- data/lib/alf/shell/command.rb +21 -0
- data/lib/alf/shell/command/exec.rb +16 -0
- data/lib/alf/shell/command/help.rb +30 -0
- data/lib/alf/shell/command/main.rb +175 -0
- data/lib/alf/shell/command/show.rb +49 -0
- data/lib/alf/shell/doc_manager.rb +83 -0
- data/lib/alf/shell/ext/signature.rb +45 -0
- data/lib/alf/shell/from_argv.rb +78 -0
- data/lib/alf/shell/loader.rb +2 -0
- data/lib/alf/shell/operator.rb +63 -0
- data/lib/alf/shell/support.rb +28 -0
- data/lib/alf/shell/version.rb +16 -0
- data/spec/integration/__database__/group.alf +3 -0
- data/spec/integration/__database__/parts.rash +6 -0
- data/spec/integration/__database__/suppliers.rash +5 -0
- data/spec/integration/__database__/suppliers_csv.csv +6 -0
- data/spec/integration/__database__/supplies.rash +12 -0
- data/spec/integration/alf/alf.db +0 -0
- data/spec/integration/alf/alf_db.cmd +1 -0
- data/spec/integration/alf/alf_db.stdout +5 -0
- data/spec/integration/alf/alf_e.cmd +1 -0
- data/spec/integration/alf/alf_e.stdout +4 -0
- data/spec/integration/alf/alf_help.cmd +1 -0
- data/spec/integration/alf/alf_help.stdout +72 -0
- data/spec/integration/alf/alf_json.cmd +1 -0
- data/spec/integration/alf/alf_json.stdout +1 -0
- data/spec/integration/alf/alf_r.cmd +1 -0
- data/spec/integration/alf/alf_r.stdout +5 -0
- data/spec/integration/alf/alf_version.cmd +1 -0
- data/spec/integration/alf/alf_version.stdout +2 -0
- data/spec/integration/alf/alf_yaml.cmd +1 -0
- data/spec/integration/alf/alf_yaml.stdout +22 -0
- data/spec/integration/alf/rel.rash +1 -0
- data/spec/integration/autonum/autonum_0.cmd +1 -0
- data/spec/integration/autonum/autonum_0.stdout +9 -0
- data/spec/integration/autonum/autonum_1.cmd +1 -0
- data/spec/integration/autonum/autonum_1.stdout +9 -0
- data/spec/integration/clip/clip_0.cmd +1 -0
- data/spec/integration/clip/clip_0.stdout +9 -0
- data/spec/integration/clip/clip_1.cmd +1 -0
- data/spec/integration/clip/clip_1.stdout +9 -0
- data/spec/integration/coerce/coerce_1.cmd +1 -0
- data/spec/integration/coerce/coerce_1.stdout +5 -0
- data/spec/integration/compact/compact_0.cmd +1 -0
- data/spec/integration/compact/compact_0.stdout +9 -0
- data/spec/integration/defaults/defaults_0.cmd +1 -0
- data/spec/integration/defaults/defaults_0.stdout +9 -0
- data/spec/integration/defaults/defaults_1.cmd +1 -0
- data/spec/integration/defaults/defaults_1.stdout +9 -0
- data/spec/integration/defaults/defaults_2.cmd +1 -0
- data/spec/integration/defaults/defaults_2.stdout +9 -0
- data/spec/integration/extend/extend_0.cmd +1 -0
- data/spec/integration/extend/extend_0.stdout +16 -0
- data/spec/integration/generator/generator_1.cmd +1 -0
- data/spec/integration/generator/generator_1.stdout +10 -0
- data/spec/integration/generator/generator_2.cmd +1 -0
- data/spec/integration/generator/generator_2.stdout +5 -0
- data/spec/integration/generator/generator_3.cmd +1 -0
- data/spec/integration/generator/generator_3.stdout +5 -0
- data/spec/integration/group/group_0.cmd +1 -0
- data/spec/integration/group/group_0.stdout +32 -0
- data/spec/integration/group/group_1.cmd +1 -0
- data/spec/integration/group/group_1.stdout +32 -0
- data/spec/integration/help/help_1.cmd +1 -0
- data/spec/integration/help/help_1.stdout +25 -0
- data/spec/integration/intersect/intersect_0.cmd +1 -0
- data/spec/integration/intersect/intersect_0.stdout +9 -0
- data/spec/integration/join/join_0.cmd +1 -0
- data/spec/integration/join/join_0.stdout +16 -0
- data/spec/integration/matching/matching_0.cmd +1 -0
- data/spec/integration/matching/matching_0.stdout +8 -0
- data/spec/integration/minus/minus_0.cmd +1 -0
- data/spec/integration/minus/minus_0.stdout +4 -0
- data/spec/integration/not-matching/not-matching_0.cmd +1 -0
- data/spec/integration/not-matching/not-matching_0.stdout +5 -0
- data/spec/integration/project/project_0.cmd +1 -0
- data/spec/integration/project/project_0.stdout +9 -0
- data/spec/integration/project/project_1.cmd +1 -0
- data/spec/integration/project/project_1.stdout +9 -0
- data/spec/integration/quota/quota_0.cmd +1 -0
- data/spec/integration/quota/quota_0.stdout +16 -0
- data/spec/integration/rank/rank_1.cmd +1 -0
- data/spec/integration/rank/rank_1.stdout +10 -0
- data/spec/integration/rank/rank_2.cmd +1 -0
- data/spec/integration/rank/rank_2.stdout +10 -0
- data/spec/integration/rank/rank_3.cmd +1 -0
- data/spec/integration/rank/rank_3.stdout +10 -0
- data/spec/integration/rank/rank_4.cmd +1 -0
- data/spec/integration/rank/rank_4.stdout +6 -0
- data/spec/integration/rank/rank_5.cmd +1 -0
- data/spec/integration/rank/rank_5.stdout +6 -0
- data/spec/integration/rename/rename_0.cmd +1 -0
- data/spec/integration/rename/rename_0.stdout +9 -0
- data/spec/integration/restrict/restrict_0.cmd +1 -0
- data/spec/integration/restrict/restrict_0.stdout +6 -0
- data/spec/integration/restrict/restrict_1.cmd +1 -0
- data/spec/integration/restrict/restrict_1.stdout +6 -0
- data/spec/integration/show/show_base.cmd +1 -0
- data/spec/integration/show/show_base.stdout +5 -0
- data/spec/integration/show/show_base_sort_1.cmd +1 -0
- data/spec/integration/show/show_base_sort_1.stdout +9 -0
- data/spec/integration/show/show_base_sort_2.cmd +1 -0
- data/spec/integration/show/show_base_sort_2.stdout +9 -0
- data/spec/integration/show/show_conflictual.cmd +1 -0
- data/spec/integration/show/show_conflictual.stdout +5 -0
- data/spec/integration/show/show_ff.cmd +1 -0
- data/spec/integration/show/show_ff.stdout +10 -0
- data/spec/integration/show/show_rash.cmd +1 -0
- data/spec/integration/show/show_rash.stdout +5 -0
- data/spec/integration/show/show_rash_pretty.cmd +1 -0
- data/spec/integration/show/show_rash_pretty.stdout +30 -0
- data/spec/integration/show/show_yaml.cmd +1 -0
- data/spec/integration/show/show_yaml.stdout +22 -0
- data/spec/integration/sort/sort_0.cmd +1 -0
- data/spec/integration/sort/sort_0.stdout +9 -0
- data/spec/integration/sort/sort_1.cmd +1 -0
- data/spec/integration/sort/sort_1.stdout +9 -0
- data/spec/integration/sort/sort_2.cmd +1 -0
- data/spec/integration/sort/sort_2.stdout +9 -0
- data/spec/integration/sort/sort_3.cmd +1 -0
- data/spec/integration/sort/sort_3.stdout +9 -0
- data/spec/integration/summarize/summarize_0.cmd +1 -0
- data/spec/integration/summarize/summarize_0.stdout +8 -0
- data/spec/integration/test_shell.rb +56 -0
- data/spec/integration/union/union_0.cmd +1 -0
- data/spec/integration/union/union_0.stdout +9 -0
- data/spec/integration/unwrap/unwrap_0.cmd +1 -0
- data/spec/integration/unwrap/unwrap_0.stdout +9 -0
- data/spec/integration/wrap/wrap_0.cmd +1 -0
- data/spec/integration/wrap/wrap_0.stdout +9 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/test_shell.rb +10 -0
- data/spec/unit/doc_manager/dynamic.md +1 -0
- data/spec/unit/doc_manager/example.md +1 -0
- data/spec/unit/doc_manager/example_1.txt +11 -0
- data/spec/unit/doc_manager/static.md +1 -0
- data/spec/unit/doc_manager/test_call.rb +43 -0
- data/spec/unit/ext/signature/test_argv2args.rb +82 -0
- data/spec/unit/ext/signature/test_to_shell.rb +103 -0
- data/spec/unit/from_argv/test_to_attr_list.rb +30 -0
- data/spec/unit/from_argv/test_to_attr_name.rb +27 -0
- data/spec/unit/from_argv/test_to_boolean.rb +32 -0
- data/spec/unit/from_argv/test_to_heading.rb +37 -0
- data/spec/unit/from_argv/test_to_ordering.rb +28 -0
- data/spec/unit/from_argv/test_to_predicate.rb +26 -0
- data/spec/unit/from_argv/test_to_renaming.rb +23 -0
- data/spec/unit/from_argv/test_to_size.rb +32 -0
- data/spec/unit/from_argv/test_to_summarization.rb +19 -0
- data/spec/unit/from_argv/test_to_tuple_computation.rb +18 -0
- data/spec/unit/from_argv/test_to_tuple_expression.rb +38 -0
- data/spec/unit/main/test_class_methods.rb +44 -0
- data/spec/unit/operator/test_autonum.rb +28 -0
- data/spec/unit/operator/test_clip.rb +29 -0
- data/spec/unit/operator/test_coerce.rb +22 -0
- data/spec/unit/operator/test_compact.rb +16 -0
- data/spec/unit/operator/test_defaults.rb +29 -0
- data/spec/unit/operator/test_extend.rb +21 -0
- data/spec/unit/operator/test_generator.rb +37 -0
- data/spec/unit/operator/test_group.rb +32 -0
- data/spec/unit/operator/test_infer_heading.rb +16 -0
- data/spec/unit/operator/test_intersect.rb +18 -0
- data/spec/unit/operator/test_join.rb +18 -0
- data/spec/unit/operator/test_matching.rb +18 -0
- data/spec/unit/operator/test_minus.rb +18 -0
- data/spec/unit/operator/test_not_matching.rb +18 -0
- data/spec/unit/operator/test_project.rb +38 -0
- data/spec/unit/operator/test_quota.rb +23 -0
- data/spec/unit/operator/test_rank.rb +30 -0
- data/spec/unit/operator/test_rename.rb +21 -0
- data/spec/unit/operator/test_restrict.rb +36 -0
- data/spec/unit/operator/test_sort.rb +49 -0
- data/spec/unit/operator/test_summarize.rb +30 -0
- data/spec/unit/operator/test_ungroup.rb +28 -0
- data/spec/unit/operator/test_union.rb +18 -0
- data/spec/unit/operator/test_unwrap.rb +28 -0
- data/spec/unit/operator/test_wrap.rb +30 -0
- data/tasks/gem.rake +8 -0
- data/tasks/test.rake +6 -0
- metadata +317 -0
@@ -0,0 +1 @@
|
|
1
|
+
alf --text rank parts -- weight
|
@@ -0,0 +1,10 @@
|
|
1
|
+
+------+-------+--------+---------+--------+-------+
|
2
|
+
| :pid | :name | :color | :weight | :city | :rank |
|
3
|
+
+------+-------+--------+---------+--------+-------+
|
4
|
+
| P1 | Nut | Red | 12.000 | London | 0 |
|
5
|
+
| P5 | Cam | Blue | 12.000 | Paris | 0 |
|
6
|
+
| P4 | Screw | Red | 14.000 | London | 2 |
|
7
|
+
| P3 | Screw | Blue | 17.000 | Oslo | 3 |
|
8
|
+
| P2 | Bolt | Green | 17.000 | Paris | 3 |
|
9
|
+
| P6 | Cog | Red | 19.000 | London | 5 |
|
10
|
+
+------+-------+--------+---------+--------+-------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text rank parts -- weight -- pos
|
@@ -0,0 +1,10 @@
|
|
1
|
+
+------+-------+--------+---------+--------+------+
|
2
|
+
| :pid | :name | :color | :weight | :city | :pos |
|
3
|
+
+------+-------+--------+---------+--------+------+
|
4
|
+
| P1 | Nut | Red | 12.000 | London | 0 |
|
5
|
+
| P5 | Cam | Blue | 12.000 | Paris | 0 |
|
6
|
+
| P4 | Screw | Red | 14.000 | London | 2 |
|
7
|
+
| P3 | Screw | Blue | 17.000 | Oslo | 3 |
|
8
|
+
| P2 | Bolt | Green | 17.000 | Paris | 3 |
|
9
|
+
| P6 | Cog | Red | 19.000 | London | 5 |
|
10
|
+
+------+-------+--------+---------+--------+------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text rank parts -- weight pid
|
@@ -0,0 +1,10 @@
|
|
1
|
+
+------+-------+--------+---------+--------+-------+
|
2
|
+
| :pid | :name | :color | :weight | :city | :rank |
|
3
|
+
+------+-------+--------+---------+--------+-------+
|
4
|
+
| P1 | Nut | Red | 12.000 | London | 0 |
|
5
|
+
| P5 | Cam | Blue | 12.000 | Paris | 1 |
|
6
|
+
| P4 | Screw | Red | 14.000 | London | 2 |
|
7
|
+
| P2 | Bolt | Green | 17.000 | Paris | 3 |
|
8
|
+
| P3 | Screw | Blue | 17.000 | Oslo | 4 |
|
9
|
+
| P6 | Cog | Red | 19.000 | London | 5 |
|
10
|
+
+------+-------+--------+---------+--------+-------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf rank parts -- weight desc -- position
|
@@ -0,0 +1,6 @@
|
|
1
|
+
{:pid => "P6", :name => "Cog", :color => "Red", :weight => 19.0, :city => "London", :position => 0}
|
2
|
+
{:pid => "P2", :name => "Bolt", :color => "Green", :weight => 17.0, :city => "Paris", :position => 1}
|
3
|
+
{:pid => "P3", :name => "Screw", :color => "Blue", :weight => 17.0, :city => "Oslo", :position => 1}
|
4
|
+
{:pid => "P4", :name => "Screw", :color => "Red", :weight => 14.0, :city => "London", :position => 3}
|
5
|
+
{:pid => "P5", :name => "Cam", :color => "Blue", :weight => 12.0, :city => "Paris", :position => 4}
|
6
|
+
{:pid => "P1", :name => "Nut", :color => "Red", :weight => 12.0, :city => "London", :position => 4}
|
@@ -0,0 +1 @@
|
|
1
|
+
alf rank parts -- weight desc pid asc -- position
|
@@ -0,0 +1,6 @@
|
|
1
|
+
{:pid => "P6", :name => "Cog", :color => "Red", :weight => 19.0, :city => "London", :position => 0}
|
2
|
+
{:pid => "P2", :name => "Bolt", :color => "Green", :weight => 17.0, :city => "Paris", :position => 1}
|
3
|
+
{:pid => "P3", :name => "Screw", :color => "Blue", :weight => 17.0, :city => "Oslo", :position => 2}
|
4
|
+
{:pid => "P4", :name => "Screw", :color => "Red", :weight => 14.0, :city => "London", :position => 3}
|
5
|
+
{:pid => "P1", :name => "Nut", :color => "Red", :weight => 12.0, :city => "London", :position => 4}
|
6
|
+
{:pid => "P5", :name => "Cam", :color => "Blue", :weight => 12.0, :city => "Paris", :position => 5}
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text rename suppliers -- name supplier_name city supplier_city
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+----------------+---------+----------------+
|
2
|
+
| :sid | :supplier_name | :status | :supplier_city |
|
3
|
+
+------+----------------+---------+----------------+
|
4
|
+
| S1 | Smith | 20 | London |
|
5
|
+
| S2 | Jones | 10 | Paris |
|
6
|
+
| S3 | Blake | 30 | Paris |
|
7
|
+
| S4 | Clark | 20 | London |
|
8
|
+
| S5 | Adams | 30 | Athens |
|
9
|
+
+------+----------------+---------+----------------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text restrict suppliers -- "status > 20"
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text restrict suppliers -- city "'London'"
|
@@ -0,0 +1 @@
|
|
1
|
+
alf show suppliers
|
@@ -0,0 +1,5 @@
|
|
1
|
+
{:sid => "S1", :name => "Smith", :status => 20, :city => "London"}
|
2
|
+
{:sid => "S2", :name => "Jones", :status => 10, :city => "Paris"}
|
3
|
+
{:sid => "S3", :name => "Blake", :status => 30, :city => "Paris"}
|
4
|
+
{:sid => "S4", :name => "Clark", :status => 20, :city => "London"}
|
5
|
+
{:sid => "S5", :name => "Adams", :status => 30, :city => "Athens"}
|
@@ -0,0 +1 @@
|
|
1
|
+
alf show --text suppliers -- city asc sid asc
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+---------+--------+
|
2
|
+
| :sid | :name | :status | :city |
|
3
|
+
+------+-------+---------+--------+
|
4
|
+
| S5 | Adams | 30 | Athens |
|
5
|
+
| S1 | Smith | 20 | London |
|
6
|
+
| S4 | Clark | 20 | London |
|
7
|
+
| S2 | Jones | 10 | Paris |
|
8
|
+
| S3 | Blake | 30 | Paris |
|
9
|
+
+------+-------+---------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf show --text suppliers -- city asc status desc sid asc
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+---------+--------+
|
2
|
+
| :sid | :name | :status | :city |
|
3
|
+
+------+-------+---------+--------+
|
4
|
+
| S5 | Adams | 30 | Athens |
|
5
|
+
| S1 | Smith | 20 | London |
|
6
|
+
| S4 | Clark | 20 | London |
|
7
|
+
| S3 | Blake | 30 | Paris |
|
8
|
+
| S2 | Jones | 10 | Paris |
|
9
|
+
+------+-------+---------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --yaml show suppliers --rash
|
@@ -0,0 +1,5 @@
|
|
1
|
+
{:sid => "S1", :name => "Smith", :status => 20, :city => "London"}
|
2
|
+
{:sid => "S2", :name => "Jones", :status => 10, :city => "Paris"}
|
3
|
+
{:sid => "S3", :name => "Blake", :status => 30, :city => "Paris"}
|
4
|
+
{:sid => "S4", :name => "Clark", :status => 20, :city => "London"}
|
5
|
+
{:sid => "S5", :name => "Adams", :status => 30, :city => "Athens"}
|
@@ -0,0 +1 @@
|
|
1
|
+
alf show --text parts --ff=%.6f
|
@@ -0,0 +1,10 @@
|
|
1
|
+
+------+-------+--------+-----------+--------+
|
2
|
+
| :pid | :name | :color | :weight | :city |
|
3
|
+
+------+-------+--------+-----------+--------+
|
4
|
+
| P1 | Nut | Red | 12.000000 | London |
|
5
|
+
| P2 | Bolt | Green | 17.000000 | Paris |
|
6
|
+
| P3 | Screw | Blue | 17.000000 | Oslo |
|
7
|
+
| P4 | Screw | Red | 14.000000 | London |
|
8
|
+
| P5 | Cam | Blue | 12.000000 | Paris |
|
9
|
+
| P6 | Cog | Red | 19.000000 | London |
|
10
|
+
+------+-------+--------+-----------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf show suppliers --rash
|
@@ -0,0 +1,5 @@
|
|
1
|
+
{:sid => "S1", :name => "Smith", :status => 20, :city => "London"}
|
2
|
+
{:sid => "S2", :name => "Jones", :status => 10, :city => "Paris"}
|
3
|
+
{:sid => "S3", :name => "Blake", :status => 30, :city => "Paris"}
|
4
|
+
{:sid => "S4", :name => "Clark", :status => 20, :city => "London"}
|
5
|
+
{:sid => "S5", :name => "Adams", :status => 30, :city => "Athens"}
|
@@ -0,0 +1 @@
|
|
1
|
+
alf show suppliers --rash --pretty
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
:sid => "S1",
|
3
|
+
:name => "Smith",
|
4
|
+
:status => 20,
|
5
|
+
:city => "London"
|
6
|
+
}
|
7
|
+
{
|
8
|
+
:sid => "S2",
|
9
|
+
:name => "Jones",
|
10
|
+
:status => 10,
|
11
|
+
:city => "Paris"
|
12
|
+
}
|
13
|
+
{
|
14
|
+
:sid => "S3",
|
15
|
+
:name => "Blake",
|
16
|
+
:status => 30,
|
17
|
+
:city => "Paris"
|
18
|
+
}
|
19
|
+
{
|
20
|
+
:sid => "S4",
|
21
|
+
:name => "Clark",
|
22
|
+
:status => 20,
|
23
|
+
:city => "London"
|
24
|
+
}
|
25
|
+
{
|
26
|
+
:sid => "S5",
|
27
|
+
:name => "Adams",
|
28
|
+
:status => 30,
|
29
|
+
:city => "Athens"
|
30
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
alf show suppliers --yaml -- sid asc
|
@@ -0,0 +1,22 @@
|
|
1
|
+
---
|
2
|
+
- :sid: S1
|
3
|
+
:name: Smith
|
4
|
+
:status: 20
|
5
|
+
:city: London
|
6
|
+
- :sid: S2
|
7
|
+
:name: Jones
|
8
|
+
:status: 10
|
9
|
+
:city: Paris
|
10
|
+
- :sid: S3
|
11
|
+
:name: Blake
|
12
|
+
:status: 30
|
13
|
+
:city: Paris
|
14
|
+
- :sid: S4
|
15
|
+
:name: Clark
|
16
|
+
:status: 20
|
17
|
+
:city: London
|
18
|
+
- :sid: S5
|
19
|
+
:name: Adams
|
20
|
+
:status: 30
|
21
|
+
:city: Athens
|
22
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text sort suppliers -- name
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+---------+--------+
|
2
|
+
| :sid | :name | :status | :city |
|
3
|
+
+------+-------+---------+--------+
|
4
|
+
| S5 | Adams | 30 | Athens |
|
5
|
+
| S3 | Blake | 30 | Paris |
|
6
|
+
| S4 | Clark | 20 | London |
|
7
|
+
| S2 | Jones | 10 | Paris |
|
8
|
+
| S1 | Smith | 20 | London |
|
9
|
+
+------+-------+---------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text sort suppliers -- name desc
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+---------+--------+
|
2
|
+
| :sid | :name | :status | :city |
|
3
|
+
+------+-------+---------+--------+
|
4
|
+
| S1 | Smith | 20 | London |
|
5
|
+
| S2 | Jones | 10 | Paris |
|
6
|
+
| S4 | Clark | 20 | London |
|
7
|
+
| S3 | Blake | 30 | Paris |
|
8
|
+
| S5 | Adams | 30 | Athens |
|
9
|
+
+------+-------+---------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text sort suppliers -- city name
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+---------+--------+
|
2
|
+
| :sid | :name | :status | :city |
|
3
|
+
+------+-------+---------+--------+
|
4
|
+
| S5 | Adams | 30 | Athens |
|
5
|
+
| S4 | Clark | 20 | London |
|
6
|
+
| S1 | Smith | 20 | London |
|
7
|
+
| S3 | Blake | 30 | Paris |
|
8
|
+
| S2 | Jones | 10 | Paris |
|
9
|
+
+------+-------+---------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text sort suppliers -- city desc name asc
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+---------+--------+
|
2
|
+
| :sid | :name | :status | :city |
|
3
|
+
+------+-------+---------+--------+
|
4
|
+
| S3 | Blake | 30 | Paris |
|
5
|
+
| S2 | Jones | 10 | Paris |
|
6
|
+
| S4 | Clark | 20 | London |
|
7
|
+
| S1 | Smith | 20 | London |
|
8
|
+
| S5 | Adams | 30 | Athens |
|
9
|
+
+------+-------+---------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text summarize supplies -- sid -- total_qty "sum{ qty }"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
def wlang(str, binding)
|
4
|
+
str.gsub(/\$\(([\S]+)\)/){ Kernel.eval($1, binding) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def _(path, file)
|
8
|
+
File.expand_path("../#{path}", file)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "Alf's alf command / " do
|
12
|
+
|
13
|
+
Path.dir.glob('**/*.cmd').each do |input|
|
14
|
+
cmd = wlang(input.readlines.first, binding)
|
15
|
+
specify{ cmd.should =~ /^alf / }
|
16
|
+
|
17
|
+
describe "#{input.basename}: #{cmd}" do
|
18
|
+
let(:argv) { Quickl.parse_commandline_args(cmd)[1..-1] }
|
19
|
+
let(:stdout) { input.sub_ext('.stdout') }
|
20
|
+
let(:stderr) { input.sub_ext('.stderr') }
|
21
|
+
let(:stdout_expected) { stdout.exists? ? wlang(stdout.read, binding) : "" }
|
22
|
+
let(:stderr_expected) { stderr.exists? ? wlang(stderr.read, binding) : "" }
|
23
|
+
|
24
|
+
before{
|
25
|
+
$oldstdout = $stdout
|
26
|
+
$oldstderr = $stderr
|
27
|
+
$stdout = StringIO.new
|
28
|
+
$stderr = StringIO.new
|
29
|
+
}
|
30
|
+
after {
|
31
|
+
$stdout = $oldstdout
|
32
|
+
$stderr = $oldstderr
|
33
|
+
$oldstdout = nil
|
34
|
+
$oldstderr = nil
|
35
|
+
}
|
36
|
+
|
37
|
+
specify{
|
38
|
+
begin
|
39
|
+
dir = Path.relative('__database__')
|
40
|
+
main = Alf::Shell::Main.new
|
41
|
+
main.database = Alf.connect(dir)
|
42
|
+
main.run(argv, __FILE__)
|
43
|
+
rescue => ex
|
44
|
+
begin
|
45
|
+
Alf::Shell::Main.handle_error(ex, main)
|
46
|
+
rescue SystemExit
|
47
|
+
$stdout << "SystemExit" << "\n"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
$stdout.string.should(eq(stdout_expected))
|
51
|
+
$stderr.string.should(eq(stderr_expected))
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text union suppliers suppliers
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+---------+--------+
|
2
|
+
| :sid | :name | :status | :city |
|
3
|
+
+------+-------+---------+--------+
|
4
|
+
| S1 | Smith | 20 | London |
|
5
|
+
| S2 | Jones | 10 | Paris |
|
6
|
+
| S3 | Blake | 30 | Paris |
|
7
|
+
| S4 | Clark | 20 | London |
|
8
|
+
| S5 | Adams | 30 | Athens |
|
9
|
+
+------+-------+---------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text unwrap suppliers -- loc_and_status
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+---------+--------+
|
2
|
+
| :sid | :name | :status | :city |
|
3
|
+
+------+-------+---------+--------+
|
4
|
+
| S1 | Smith | 20 | London |
|
5
|
+
| S2 | Jones | 10 | Paris |
|
6
|
+
| S3 | Blake | 30 | Paris |
|
7
|
+
| S4 | Clark | 20 | London |
|
8
|
+
| S5 | Adams | 30 | Athens |
|
9
|
+
+------+-------+---------+--------+
|
@@ -0,0 +1 @@
|
|
1
|
+
alf --text wrap suppliers -- city status -- loc_and_status
|
@@ -0,0 +1,9 @@
|
|
1
|
+
+------+-------+--------------------------------+
|
2
|
+
| :sid | :name | :loc_and_status |
|
3
|
+
+------+-------+--------------------------------+
|
4
|
+
| S1 | Smith | {:city=>"London", :status=>20} |
|
5
|
+
| S2 | Jones | {:city=>"Paris", :status=>10} |
|
6
|
+
| S3 | Blake | {:city=>"Paris", :status=>30} |
|
7
|
+
| S4 | Clark | {:city=>"London", :status=>20} |
|
8
|
+
| S5 | Adams | {:city=>"Athens", :status=>30} |
|
9
|
+
+------+-------+--------------------------------+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'alf-shell'
|
3
|
+
require "rspec"
|
4
|
+
|
5
|
+
module Helpers
|
6
|
+
|
7
|
+
def examples_database(&bl)
|
8
|
+
Alf.examples
|
9
|
+
end
|
10
|
+
|
11
|
+
def suppliers
|
12
|
+
Alf::Algebra.named_operand(:suppliers, examples_database)
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |c|
|
18
|
+
c.include Helpers
|
19
|
+
c.extend Helpers
|
20
|
+
c.filter_run_excluding :ruby19 => (RUBY_VERSION < "1.9")
|
21
|
+
end
|
data/spec/test_shell.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
#(command_name)
|
@@ -0,0 +1 @@
|
|
1
|
+
!(alf autonum suppliers -- unique_id)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$ alf autonum suppliers -- unique_id
|
2
|
+
|
3
|
+
+------+-------+---------+--------+------------+
|
4
|
+
| :sid | :name | :status | :city | :unique_id |
|
5
|
+
+------+-------+---------+--------+------------+
|
6
|
+
| S1 | Smith | 20 | London | 0 |
|
7
|
+
| S2 | Jones | 10 | Paris | 1 |
|
8
|
+
| S3 | Blake | 30 | Paris | 2 |
|
9
|
+
| S4 | Clark | 20 | London | 3 |
|
10
|
+
| S5 | Adams | 30 | Athens | 4 |
|
11
|
+
+------+-------+---------+--------+------------+
|