Skip to content

Commit 0554c22

Browse files
committed
- Allow disabling compact flag expansion (-abc to -a -b -c)
1 parent ff65c10 commit 0554c22

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

lib/bashly/settings.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ class Settings
33
class << self
44
include AssetHelper
55

6-
attr_writer :source_dir, :target_dir, :lib_dir, :strict, :tab_indent
6+
attr_writer :compact_short_flags, :source_dir, :target_dir,
7+
:lib_dir, :strict, :tab_indent
78

89
def source_dir
910
@source_dir ||= get :source_dir
@@ -25,6 +26,10 @@ def tab_indent
2526
@tab_indent ||= get :tab_indent
2627
end
2728

29+
def compact_short_flags
30+
@compact_short_flags ||= get :compact_short_flags
31+
end
32+
2833
def env
2934
@env ||= get(:env)&.to_sym
3035
end

lib/bashly/templates/settings.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ strict: false
2222
# (every 2 leading spaces will be converted to a tab character)
2323
tab_indent: false
2424

25+
# When true, the generated script will consider any argument in the form of
26+
# `-abc` as if it is `-a -b -c`.
27+
compact_short_flags: true
28+
2529
# Set to 'production' or 'development':
2630
# - production generate a smaller script, without file markers
2731
# - development generate with file markers

lib/bashly/views/command/normalize_input.gtx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
> elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
1212
> input+=("${BASH_REMATCH[1]}")
1313
> input+=("${BASH_REMATCH[2]}")
14+
15+
if Settings.compact_short_flags
1416
> elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
1517
> flags="${BASH_REMATCH[1]}"
1618
> for (( i=0 ; i < ${#flags} ; i++ )); do
1719
> input+=("-${flags:i:1}")
1820
> done
21+
end
22+
1923
> else
2024
> input+=("$arg")
2125
> fi

0 commit comments

Comments
 (0)