mcm_cli

package module
v0.0.0-...-4f42b43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2023 License: AGPL-3.0 Imports: 26 Imported by: 0

README

mcm-cli

mcm-cli is the CLI element of the Mixed Content Mixenator (XML,HTML,Markdown). Written in Go. Aimed at LwDITA.

License

Note that this is GNU Affero -licensed, not MIT-licensed like most of the libraries it uses. This means that use over a network is distribution, requiring disclosure of modifications to source code.

Documentation

Overview

Package mcm-cli 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

Constants

This section is empty.

Variables

View Source
var AllGLinks mcfile.GLinks

AllGLinks gathers all GLinks in the current run's input set.

View Source
var DB_FILENAME = "mmmc.db"
View Source
var LOG_LEVEL_EXEC_STAGES = LU.LevelDbg
View Source
var LOG_LEVEL_FILE_READING = LU.LevelDbg
View Source
var LOG_LEVEL_REF_LINKING = LU.LevelDbg
View Source
var LOG_LEVEL_WEB = LU.LevelDbg

Functions

func CLI

func CLI() error

CLI parses the contents of os.Args and then processes them.

NOTE: You can assign your own set of mock arguments to os.Args - it is writeable! This can 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.

NOTE: Do not use logging in the code until the point where the command line invocation has been sorted out.

Outline of operation:

  1. flargs (command line flag arguments) are defined in a func init(), so that they are available for a no-CLI-arg help message
  2. Check for no-CLI-arg invocation that gets a help message and exits
  3. InitLogging
  4. PreParse() does preliminaries like library demos
  5. NewXmlAppCfg creates XmlAppCfg config from CLI arguments
  6. NewXmlAppEnv creates XmlAppEnv env'mt from XmlAppCfg
  7. XmlAppEnv.Exec() to Get Things Done
  8. If REST port nr given, run web UI

.

func DisableAllFlags

func DisableAllFlags()

DisableAllFlags operates on flag.CommandLine

func DisableFlags

func DisableFlags(s string)

DisableFlags operates on flag.CommandLine

func EnableAllFlags

func EnableAllFlags()

EnableAllFlags operates on flag.CommandLine

func EnableFlags

func EnableFlags(s string)

EnableFlags operates on flag.CommandLine

func EnvarNameFromFlagName

func EnvarNameFromFlagName(s string) string

func FlagNameFromEnvarName

func FlagNameFromEnvarName(s string) string

func HasFlag

func HasFlag(haystack []string, needle string) bool

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 PreParse

func PreParse()

PreParse does demo type stuff and can be skipped; it does use (and demo) mlog's L.L

func RunRest

func RunRest(portNr int) error

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

func RunWeb(portNr int) error

Does not launch a goroutine. Call with env.WebPort . 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 StcRootHdlr

func StcRootHdlr(w http.ResponseWriter, r *http.Request)

func TopicRootHdlr

func TopicRootHdlr(w http.ResponseWriter, r *http.Request)

Types

type AllFlargs

type AllFlargs struct {
	// contains filtered or unexported fields
}

func (AllFlargs) String

func (a AllFlargs) String() string

type ContentityProcessor

type ContentityProcessor func(
	p *mcfile.Contentity, e error) (*mcfile.Contentity, error)

ContentityProcessor (seee 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.

type ExpanDir

type ExpanDir struct {
	DirCt, FileCt,
	ItemCt int
	CtFS *mcfile.ContentityFS
}

type XmlAppCfg

type XmlAppCfg struct {
	AppName     string
	CmdTail     []string
	XmllintPath string
	AllFlargs
}

XmlAppCfg can probably be used with various 3rd-party utilities.

type XmlAppEnv

type XmlAppEnv struct {
	repo.SimpleRepo
	Infiles       []FU.PathProps
	Indirs        []FU.PathProps
	Inexpandirs   []ExpanDir
	Outdir, Dbdir FU.PathProps // NOT ptr! Barfs at startup.
	Xmlcatfile    FU.PathProps // NOT ptr! Barfs at startup.
	Xmlschemasdir FU.PathProps // 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

func (env *XmlAppEnv) Exec() error

func (*XmlAppEnv) ProcessDatabaseArgs

func (env *XmlAppEnv) ProcessDatabaseArgs() error

ProcessDatabaseArgs should be able to process either a new DB OR an existing DB. .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL