hzDocs
hzDocs
Articles / Postshedzr.comIntroduction

Guide

Your First CLI AppConcise Version
Step by step
Concepts
CommandCommand: Invoke programCommand: Presetting ArgsCommand: RedirectToCommand: DynCommandCommand: Aliases from ConfigCommand: Event HandlersFlagFlag: RequiredFlag: Toggle GroupFlag: Valid ArgsFlag: `Head -1` styleFlag: External EditorFlag: NegatableFlag: Leading Plus Sign `+`Flag: Event Handlers解析结果Builtin Commands & Flags帮助子系统Shared App辨析Package level functionsWithOptsBackstage
Howto ...
Auto-close the ClosersRead config into structUsing is DetectorsUsing Store

References

What's New
Packages

Others

Examples
Blueprint
产品发布
产品发布之前
Concepts

Flag: Event Handlers

OnXXX event handlers...

Event Handlers associated with a flag

The standard events and its handlers are:

  • .OnParseValue(...OnParseValueHandler)
  • .OnMatched(...OnMatchedHandler)
  • .OnChanging(...OnChangingHandler)
  • .OnChanged(...OnChangedHandler)
  • .OnSet(...OnSetHandler)

All of these handlers are specific for each phrases in cmdr runner working: a subcommand will be parsed (OnParseValue), parsed ok (OnMatched), a flag parsed (OnMatched) and the raw string are been parsed as its value (OnChanging), and the new value accepted (OnChanged), or a store entry value was been changed programmatically (OnSet).

The differences of OnSet and OnChanged is, the first one will be called while cmd.Store().Set("some.key", newval) ran, it means a programmatic modification. And the last one will be called while cmdr is parsing the command-line arguments.

cmdr-loaders works with cmdr main library, and assumes its loading action is OnLoading(cb) wrapped. So in the time the OnSet won't be triggered.

After loaded, any modifications are recorded, that would be a changeset. The modifications will be written back to a Alternative config file at terminating app. The Write-back feature can be descibed at Here.

额外的话题

Required

Toggle Group

Valid Args

Head Like

External Tool

Plus Sign

Event Handlers

What is Next?

How is this guide?

Last updated on

Flag: Leading Plus Sign `+`

The leading plus sign can be recognized

解析结果

the matched states of cmdr ...

On this page

Event Handlers associated with a flag
额外的话题