ResolveInput determines the input source and returns a reader and cleanup function Priority: stdin flag > explicit file argument > default tasks.md file
(args []string)
| 30 | // ResolveInput determines the input source and returns a reader and cleanup function |
| 31 | // Priority: stdin flag > explicit file argument > default tasks.md file |
| 32 | func (ir *InputResolver) ResolveInput(args []string) (io.Reader, func() error, error) { |
| 33 | // Case 1: Read from stdin |
| 34 | if ir.useStdin { |
| 35 | if ir.verbose { |
| 36 | fmt.Fprintln(os.Stderr, "Reading from stdin...") |
| 37 | } |
| 38 | return os.Stdin, func() error { return nil }, nil |
| 39 | } |
| 40 | |
| 41 | // Case 2: Explicit file path provided |
| 42 | if len(args) > 0 { |
| 43 | filePath := args[0] |
| 44 | return ir.openFile(filePath) |
| 45 | } |
| 46 | |
| 47 | // Case 3: Default to tasks.md in current directory |
| 48 | return ir.openFile(DefaultTaskFile) |
| 49 | } |
| 50 | |
| 51 | // openFile opens a file and returns a reader and cleanup function |
| 52 | func (ir *InputResolver) openFile(filePath string) (io.Reader, func() error, error) { |