Documentation ¶
Overview ¶
Package m5cli provides a generic command line argument processing capability for XML-oriented programs. It provides a large set of useful arguments that can be individually (or as a group) enabled or disabled (i.e. hidden).
The package imports github.com/fbaube/(fileutils,stringutils,wasmutils) .
Index ¶
- Variables
- func CLI(args []string) error
- func DoSamples()
- func HomeHandler(w http.ResponseWriter, r *http.Request)
- func InitLogging(appName string)
- func MapRootHdlr(w http.ResponseWriter, r *http.Request)
- func RunRest(portNr int) error
- func RunWeb(portNr int) error
- func StcRootHdlr(w http.ResponseWriter, r *http.Request)
- func TopicRootHdlr(w http.ResponseWriter, r *http.Request)
- type AllFlargs
- type ContentityProcessor
- type XmlAppCfg
- type XmlAppEnv
Constants ¶
This section is empty.
Variables ¶
var AllGLinks mcfile.GLinks
AllGLinks gathers all GLinks in the current run's input set.
var LOG_LEVEL_EXEC_STAGES = LU.LevelDebug
var LOG_LEVEL_FILE_INTRO = LU.LevelInfo // 6
var LOG_LEVEL_FILE_READING = LU.LevelOkay // 5
var LOG_LEVEL_REF_LINKING = LU.LevelInfo // 6
var LOG_LEVEL_WEB = LU.LevelDebug
Functions ¶
func CLI ¶
CLI parses the arguments passed in (tipicly os.Args) and then processes them; therefore it is very easy to pass in whatever arguments are suitable for testing.
NOTE: os.Args is writable so you can also assign your own set of argument - this might be useful for testing or for WASM usage.
An error from this func is returned unmodified and unprocessed, and so it is up to the caller to sort out its severity and how to handle it (and perhaps what to return to the shell via os.Exit).
NOTE: Do not use logging in the code until the point where the command line invocation has been sorted out.
Outline of operation (possibly OBS):
- flargs (command line "flag arguments") are defined in a func init(), so that they are available for a no-CLI-arg help message
- Check for no-CLI-arg invocation that gets a help message and exits
- InitLogging
- Samples() can do library demos and other very meta stuff
- NewXmlAppCfg creates XmlAppCfg config from CLI arguments
- NewXmlAppEnv creates XmlAppEnv env'mt from XmlAppCfg
- XmlAppEnv.Exec() to Get Things Done
- If REST port nr given, run web UI
.
func DoSamples ¶
func DoSamples()
DoSamples does demo type stuff and can be skipped; it does use (and demo) mlog's L.L
func HomeHandler ¶
func HomeHandler(w http.ResponseWriter, r *http.Request)
func InitLogging ¶
func InitLogging(appName string)
InitLogging starts with Targets[] empty, then 1) adds a console logger (i.e. Stdout), 2) adds a file logger named "[appName].log", 3) opens them both, 4) outputs a few demo log records
func MapRootHdlr ¶
func MapRootHdlr(w http.ResponseWriter, r *http.Request)
func RunRest ¶
Does not launch a goroutine. Call with env.RestPort . Uses Gorilla mux, mainly cos now it's in archive mode. Instructions for usage are found [here](https://github.com/gorilla/mux#examples) or in alternate format github.com/gorilla/mux or in alternate format mux or in alternate format "[muxdox]"
[muxdox]: https://github.com/gorilla/mux#examples .
func RunWeb ¶
Notes:
- Does not launch a goroutine.
- Call with env.WebPort .
- Used Gorilla mux, but now use pilot version of new Go ServeMux.
Dedicated servers:
- /events :: SSE
- /ws :: websocket upgrader
- /rest :: REST server (on a different port nr)
- /htmx :: htmx responder (??; https://github.com/angelofallars/htmx-go)
Main server (with h2c):
- /all :: list of all endpoints
- / :: something bland
- /app :: the wasm SPA
- /static :: static content
- /about
- /contact
- /health (or?)
- /db .
func StcRootHdlr ¶
func StcRootHdlr(w http.ResponseWriter, r *http.Request)
func TopicRootHdlr ¶
func TopicRootHdlr(w http.ResponseWriter, r *http.Request)
Types ¶
type ContentityProcessor ¶
type ContentityProcessor func( p *mcfile.Contentity, e error) (*mcfile.Contentity, error)
ContentityProcessor (see ContentityStage !!) is most probably the best way to go. It preserves order of processing of MCFile's (unlike iterating thru a map of them), and the func signature is most def in the Go style, and the style IS CHAINABLE.
Note that to declare a func that is a ContentityProcessor, the func's signature is the RH side of this, NOT the LH side: don't try to declare a "ContentityProcessor" named as such. .
type XmlAppEnv ¶
type XmlAppEnv struct { DR.SimpleRepo Infiles []FU.FSItem Indirs []FU.FSItem IndirFSs []mcfile.ContentityFS // was: []ExpanDir Outdir, Dbdir FU.FSItem // NOT ptr! Barfs at startup. Xmlcatfile FU.FSItem // NOT ptr! Barfs at startup. Xmlschemasdir FU.FSItem // NOT ptr! Barfs at startup. // Result of processing CLI arg for input file(s) IsSingleFile bool // Result of processing CLI args -c & -s *XU.XmlCatalogFile PrittOutput io.Writer // contains filtered or unexported fields }
func (*XmlAppEnv) Exec ¶
Exec does all execution of all stages for every mcfile.Contentity, altho only after all prep has already been done by other funcs. The key input is an *XmlAppEnv. .
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package exec is home to functions called from m5's cli/Exec(), which is where all the "real work" gets done.
|
Package exec is home to functions called from m5's cli/Exec(), which is where all the "real work" gets done. |