File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -70,3 +70,34 @@ function moulti_type {
70
70
# No sleep because this hack is already inefficient enough.
71
71
done
72
72
}
73
+
74
+ MOULTI_NEW_STEP_PATTERN=' ^([-=#@]+)(\s*)(.+?)\2\1$'
75
+
76
+ function moulti_process_lines {
77
+ # Optional user hooks:
78
+ command -v moulti_make_step > /dev/null && custom_make_step=1
79
+ command -v moulti_inspect_line > /dev/null && inspect_line=1
80
+ # Main loop:
81
+ local step_counter=0
82
+ while read -r line; do
83
+ if [[ " ${line} " =~ ${MOULTI_NEW_STEP_PATTERN} ]]; then
84
+ (( ++ step_counter))
85
+ local prev_id=" ${step_id} "
86
+ local next_id=" $$ _${step_counter} "
87
+ if [ " ${custom_make_step} " ]; then
88
+ step_id=$( moulti_make_step " ${prev_id} " " ${next_id} " " ${line} " " ${BASH_REMATCH[@]} " < /dev/null)
89
+ [ " ${step_id} " ] || step_id=" ${prev_id} "
90
+ else
91
+ step_id=" ${next_id} "
92
+ moulti step add " ${step_id} " --title=" ${line} " --bottom-text=' ' --scroll-on-activity=-1 < /dev/null
93
+ fi
94
+ # Redirect stdout to `moulti pass our_new_step`
95
+ exec > >( moulti pass " ${step_id} " )
96
+ fi
97
+ if [ " ${inspect_line} " ]; then
98
+ moulti_inspect_line " ${line} " " ${step_id} " < /dev/null
99
+ else
100
+ printf ' %s\n' " ${line} "
101
+ fi
102
+ done
103
+ }
You can’t perform that action at this time.
0 commit comments