Skip to content

Commit

Permalink
Better error message when no code blocks were found in project-mode (#…
Browse files Browse the repository at this point in the history
…316)

* Case by case

* Confusing to call out named

Co-authored-by: Max Stoumen <[email protected]>

---------

Co-authored-by: Max Stoumen <[email protected]>
  • Loading branch information
sourishkrout and mxsdev authored Jun 27, 2023
1 parent a00a9b2 commit ea35bbc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/cmd/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ func tuiCmd() *cobra.Command {
blocks = sortBlocks(blocks)

if len(blocks) == 0 {
return errors.Errorf("no code blocks in %s", fFileName)
if fFileMode {
return errors.Errorf("no code blocks in %s", fFileName)
}
if !fAllowUnnamed {
return errors.Errorf("no named code blocks, consider adding flag --allow-unnamed")
}
return errors.Errorf("no code blocks")
}

if visibleEntries <= 0 {
Expand Down

0 comments on commit ea35bbc

Please sign in to comment.