1#!/bin/bash
2
3options=(
4 "auto_height_editor"
5 "avatar"
6 "button"
7 "checkbox"
8 "context_menu"
9 "cursor"
10 "disclosure"
11 "focus"
12 "icon"
13 "icon_button"
14 "keybinding"
15 "label"
16 "list"
17 "list_header"
18 "list_item"
19 "overflow_scroll"
20 "scroll"
21 "tab"
22 "tab_bar"
23 "text"
24 "viewport_units"
25 "z_index"
26 "picker"
27)
28
29run_story() {
30 echo "Running story: $1"
31 cargo run -p storybook2 -- "$1"
32}
33
34if [ "$#" -gt 0 ]; then
35 story_arg="$1"
36 # Add prefix 'components/' if not present
37 if [[ $story_arg != components/* ]]; then
38 story_arg="components/$story_arg"
39 fi
40 # Check if the provided story is a valid option
41 for opt in "${options[@]}"; do
42 if [[ "components/$opt" == "$story_arg" ]]; then
43 run_story "$story_arg"
44 exit
45 fi
46 done
47 echo "Invalid story name: $1"
48 exit 1
49fi
50
51prompt="Please select a story:"
52PS3="$prompt "
53select story in "${options[@]}"; do
54 if [[ -n $story ]]; then
55 run_story "components/$story"
56 break
57 else
58 echo "Invalid option"
59 fi
60done