Skip to content

Commit

Permalink
Use 'emit --info', 'emit --verbose', ... (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
floitsch authored Oct 2, 2024
1 parent 7640384 commit d32f607
Show file tree
Hide file tree
Showing 4 changed files with 321 additions and 72 deletions.
14 changes: 7 additions & 7 deletions examples/ui.toit
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import cli show *

some-chatty-method cli/Cli:
ui := cli.ui
ui.debug "This is a debug message."
ui.verbose "This is a verbose message."
ui.inform "This is an information message."
ui.warn "This is a warning message."
ui.error "This is an error message."
ui.interactive "This is an interactive message."
ui.emit --debug "This is a debug message."
ui.emit --verbose "This is a verbose message."
ui.emit --info "This is an information message."
ui.emit --warning "This is a warning message."
ui.emit --error "This is an error message."
ui.emit --interactive "This is an interactive message."
// By convention, 'result' calls should only happen in the method that
// initially received the Invocation object.
// For demonstration purposes, we call it here.
ui.result "This is a result message."
ui.emit --result "This is a result message."

emit-structured cli/Cli:
ui := cli.ui
Expand Down
2 changes: 1 addition & 1 deletion src/parser_.toit
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Parser_:
// Otherwise, ignore the ui that was determined through the command line and
// print the usage on stderr, followed by an exit 1.
ui := test-ui_ or (Ui --level=Ui.QUIET-LEVEL --printer=StderrPrinter_)
ui.error str
ui.emit --error str
help-command_ path [] --invoked-command=invoked-command_ --ui=ui
ui.abort
unreachable
Expand Down
Loading

0 comments on commit d32f607

Please sign in to comment.