|
| 1 | +//go:build ignore |
| 2 | +// +build ignore |
| 3 | + |
| 4 | +/* |
| 5 | + * Copyright (c) 2026-Present, Okta, Inc. |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +// This is a demo script to showcase the fuzzy search picker functionality. |
| 21 | +// Run this demo to see how the picker works with example AWS IAM roles. |
| 22 | +// |
| 23 | +// Usage: |
| 24 | +// |
| 25 | +// go run examples/picker_demo.go |
| 26 | +package main |
| 27 | + |
| 28 | +import ( |
| 29 | + "fmt" |
| 30 | + "os" |
| 31 | + |
| 32 | + "github.com/okta/okta-aws-cli/v2/internal/picker" |
| 33 | +) |
| 34 | + |
| 35 | +func main() { |
| 36 | + // Example AWS IAM roles with fake account IDs for demonstration |
| 37 | + roles := []string{ |
| 38 | + "arn:aws:iam::123456789012:role/Admin", |
| 39 | + "arn:aws:iam::123456789012:role/Developer", |
| 40 | + "arn:aws:iam::123456789012:role/ReadOnly", |
| 41 | + "arn:aws:iam::123456789012:role/DevOps-Engineer", |
| 42 | + "arn:aws:iam::123456789012:role/Security-Analyst", |
| 43 | + "arn:aws:iam::987654321098:role/Production-Admin", |
| 44 | + "arn:aws:iam::987654321098:role/Production-Developer", |
| 45 | + "arn:aws:iam::987654321098:role/Production-ReadOnly", |
| 46 | + "arn:aws:iam::111222333444:role/Staging-Admin", |
| 47 | + "arn:aws:iam::111222333444:role/Staging-Developer", |
| 48 | + "arn:aws:iam::555666777888:role/QA-Tester", |
| 49 | + "arn:aws:iam::555666777888:role/QA-Lead", |
| 50 | + "arn:aws:iam::999000111222:role/Data-Engineer", |
| 51 | + "arn:aws:iam::999000111222:role/Data-Scientist", |
| 52 | + "arn:aws:iam::999000111222:role/ML-Engineer", |
| 53 | + } |
| 54 | + |
| 55 | + fmt.Println("=== Okta AWS CLI - Fuzzy Search Picker Demo ===") |
| 56 | + fmt.Println() |
| 57 | + fmt.Println("Tips:") |
| 58 | + fmt.Println(" • Type to filter roles (searches role name, not full ARN)") |
| 59 | + fmt.Println(" • Use ↑/↓ arrows to navigate") |
| 60 | + fmt.Println(" • Press Enter to select") |
| 61 | + fmt.Println(" • Press Esc to cancel") |
| 62 | + fmt.Println() |
| 63 | + |
| 64 | + selected, err := picker.Pick("Choose an AWS IAM Role:", roles) |
| 65 | + if err != nil { |
| 66 | + fmt.Fprintf(os.Stderr, "Error: %v\n", err) |
| 67 | + os.Exit(1) |
| 68 | + } |
| 69 | + |
| 70 | + fmt.Println() |
| 71 | + fmt.Printf("✓ Selected: %s\n", selected) |
| 72 | +} |
0 commit comments