zed/script/storybook
2023-12-14 11:42:08 -05:00

61 lines
1010 B
Bash
Executable File

#!/bin/bash
options=(
"auto_height_editor"
"avatar"
"button"
"checkbox"
"context_menu"
"cursor"
"disclosure"
"focus"
"icon"
"icon_button"
"keybinding"
"label"
"list"
"list_header"
"list_item"
"overflow_scroll"
"scroll"
"tab"
"tab_bar"
"text"
"viewport_units"
"z_index"
"picker"
)
run_story() {
echo "Running story: $1"
cargo run -p storybook2 -- "$1"
}
if [ "$#" -gt 0 ]; then
story_arg="$1"
# Add prefix 'components/' if not present
if [[ $story_arg != components/* ]]; then
story_arg="components/$story_arg"
fi
# Check if the provided story is a valid option
for opt in "${options[@]}"; do
if [[ "components/$opt" == "$story_arg" ]]; then
run_story "$story_arg"
exit
fi
done
echo "Invalid story name: $1"
exit 1
fi
prompt="Please select a story:"
PS3="$prompt "
select story in "${options[@]}"; do
if [[ -n $story ]]; then
run_story "components/$story"
break
else
echo "Invalid option"
fi
done