Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for options and flags #8

Merged
merged 4 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ for now. If you have suggestions - open an Issue or a Pull Request.
- [x] No dynamic dispatch
- [x] Configurable memory usage
- [x] Declaration of commands with enums
- [x] Options and flags support
- [x] Left/right support (move inside current input)
- [x] Parsing of arguments to common types
- [x] Autocompletion of command names (with tab)
Expand All @@ -34,7 +35,6 @@ for now. If you have suggestions - open an Issue or a Pull Request.
- [x] Formatted write with [ufmt](https://github.com/japaric/ufmt)
- [x] No panicking branches in generated code, when optimized
- [x] Any byte-stream interface is supported (`embedded_io::Write` as output stream, input bytes are given one-by-one)
- [ ] Move inside current input with left/right keypress
- [ ] Colors through ANSI escape sequences
- [ ] Navigation through history with search of current input
- [ ] Support wrapping of generated str slices in user macro (useful for arduino progmem)
Expand Down
59 changes: 45 additions & 14 deletions demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,39 @@
# ffmpeg -i embedded-cli.mp4 frame%04d.png
# gifski -o demo.gif -Q 50 frame*.png

SPEED=1

declare -i DELAY=(300)/SPEED
declare -i LONGER_DELAY=(350)/SPEED

type () {
xdotool type --delay 300 -- "$1"
xdotool type --delay $DELAY -- "$1"
}
submit () {
xdotool key --delay 500 Return
xdotool key --delay $LONGER_DELAY Return
}
backspace () {
local repeat=${1:-1}
xdotool key --delay 400 --repeat $repeat BackSpace
xdotool key --delay $DELAY --repeat $repeat BackSpace
}
tab () {
xdotool key --delay 500 Tab
xdotool key --delay $LONGER_DELAY Tab
}
left () {
local repeat=${1:-1}
xdotool key --delay 400 --repeat $repeat Left
xdotool key --delay $DELAY --repeat $repeat Left
}
right () {
local repeat=${1:-1}
xdotool key --delay 400 --repeat $repeat Right
xdotool key --delay $DELAY --repeat $repeat Right
}
up () {
local repeat=${1:-1}
xdotool key --delay 800 --repeat $repeat Up
xdotool key --delay $LONGER_DELAY --repeat $repeat Up
}
down () {
local repeat=${1:-1}
xdotool key --delay 800 --repeat $repeat Down
xdotool key --delay $LONGER_DELAY --repeat $repeat Down
}

echo "Demo started"
Expand All @@ -57,12 +62,9 @@ submit
type "h"
tab

sleep 0.5

type "l"
tab

sleep 0.5
submit

up
Expand All @@ -72,13 +74,23 @@ left 2
type "e"
submit

sleep 0.5

up 2

type "Rust"
submit

up
type " -V"
submit

up
backspace
type "-verbose"
submit

type "hello -- --Rust--"
submit

type "got-l"
left 5
type "help "
Expand All @@ -95,7 +107,7 @@ tab
type "-"
tab

type "12"
type "--led 12"
submit

up 2
Expand All @@ -109,13 +121,32 @@ submit

up
type " 123 789"
submit

up
backspace 3
type "456"
left 4
backspace 2
left
type "--id "
right
type "01"
submit

type "test \"101 456\""
submit

up
left 4
backspace 4
type "\\\"abc\\\" "
submit

up
type " -- --arg"
submit

# Wait until keys disappear
sleep 5
echo "Demo is finished"
Loading
Loading