File tree Expand file tree Collapse file tree 10 files changed +103
-7
lines changed Expand file tree Collapse file tree 10 files changed +103
-7
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ def self.runner
1515 runner . route 'generate' , to : Commands ::Generate
1616 runner . route 'add' , to : Commands ::Add
1717 runner . route 'doc' , to : Commands ::Doc
18+ runner . route 'shell' , to : Commands ::Shell unless ENV [ 'BASHLY_SHELL' ]
1819
1920 runner
2021 end
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ module Bashly
22 module Commands
33 class Doc < Base
44 summary 'Show bashly reference documentation'
5- help 'This command displays bite-sized help for all the bashly configuration options in the terminal.'
65
76 usage 'bashly doc [SEARCH] [--index]'
87 usage 'bashly doc (-h|--help)'
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ module Bashly
22 module Commands
33 class Init < Base
44 summary 'Initialize a new workspace'
5- help 'This command will create the source folder, and place a template configuration file in it. '
5+ help 'Create the bashly source folder, and place a template configuration file in it'
66
77 usage 'bashly init [--minimal]'
88 usage 'bashly init (-h|--help)'
Original file line number Diff line number Diff line change 1+ module Bashly
2+ module Commands
3+ class Shell < Base
4+ summary 'Start an interactive bashly shell'
5+ help 'Start an interactive shell where you can run bashly commands'
6+
7+ usage 'bashly shell'
8+ usage 'bashly shell (-h|--help)'
9+
10+ def run
11+ ENV [ 'BASHLY_SHELL' ] = '1'
12+ terminal . start
13+ end
14+
15+ private
16+
17+ def terminal
18+ @terminal ||= begin
19+ terminal = MisterBin ::Terminal . new runner , {
20+ autocomplete : autocomplete ,
21+ show_usage : true ,
22+ prompt : "\n \e [33m\e [1mbashly\e [0m > " ,
23+ }
24+
25+ terminal . on ( 'help' ) { runner . run %w[ --help ] }
26+ terminal . on ( 'version' ) { runner . run %w[ --version ] }
27+ terminal
28+ end
29+ end
30+
31+ def runner
32+ @runner ||= Bashly ::CLI . runner
33+ end
34+
35+ def autocomplete
36+ @autocomplete ||= %w[ help version ] + runner . commands . keys
37+ end
38+ end
39+ end
40+ end
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Commands:
77 generate Generate the bash script and required files
88 add Add extra features and customization to your script
99 doc Show bashly reference documentation
10+ shell Start an interactive bashly shell
1011
1112Help: bashly COMMAND --help
1213Docs: https://bashly.dannyb.co
Original file line number Diff line number Diff line change 11Show bashly reference documentation
22
3- This command displays bite-sized help for all the bashly configuration options
4- in the terminal.
5-
63Usage:
74 bashly doc [SEARCH] [--index]
85 bashly doc (-h|--help)
Original file line number Diff line number Diff line change 11Initialize a new workspace
22
3- This command will create the source folder, and place a template configuration
4- file in it.
3+ Create the bashly source folder, and place a template configuration file in it
54
65Usage:
76 bashly init [--minimal]
Original file line number Diff line number Diff line change 1+ Bashly - Bash CLI Generator
2+
3+ Commands:
4+ init Initialize a new workspace
5+ preview Generate the bash script to STDOUT
6+ validate Scan the configuration file for errors
7+ generate Generate the bash script and required files
8+ add Add extra features and customization to your script
9+ doc Show bashly reference documentation
10+
11+ Help: bashly COMMAND --help
12+ Docs: https://bashly.dannyb.co
Original file line number Diff line number Diff line change 1+ Start an interactive bashly shell
2+
3+ Start an interactive shell where you can run bashly commands
4+
5+ Usage:
6+ bashly shell
7+ bashly shell (-h|--help)
8+
9+ Options:
10+ -h --help
11+ Show this help
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ describe Commands ::Shell do
4+ subject { described_class . new }
5+
6+ context 'with --help' do
7+ it 'shows long usage' do
8+ expect { subject . execute %w[ terminal --help ] } . to output_approval ( 'cli/shell/help' )
9+ end
10+ end
11+
12+ context 'without parameters' do
13+ let ( :terminal_double ) { instance_double MisterBin ::Terminal , start : nil , on : nil }
14+
15+ it 'runs MisterBin::Terminal' do
16+ allow ( MisterBin ::Terminal ) . to receive ( :new ) . and_return ( terminal_double )
17+ expect ( terminal_double ) . to receive ( :start )
18+ subject . execute %w[ shell ]
19+ end
20+ end
21+
22+ context 'with in-terminal commands' do
23+ before do
24+ ENV [ 'BASHLY_SHELL' ] = nil
25+ allow ( Readline ) . to receive ( :readline ) . and_return ( *input )
26+ end
27+
28+ context 'with exit command' do
29+ let ( :input ) { [ 'exit' ] }
30+
31+ it 'starts a terminal and shows CLI usage' do
32+ expect { subject . execute %w[ shell ] } . to output_approval 'cli/shell/boot'
33+ end
34+ end
35+ end
36+ end
You can’t perform that action at this time.
0 commit comments