Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Introduce ABNF CLI #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

jweisscrypto
Copy link

This PR introduces a CLI to ABNF that enables CLI automation within a CI/CD pipeline. It adopts the Cobra framework, used in many Go projects such as Kubernetes, Hugo, and GitHub CLI to name a few. The README was updated to reflect the new CLI capabilities.

The automation is defined through an abnf.yml file that (by default) is expected in the working directory, but can be explicitly specified with a -f flag to indicate an alternate location. For those at the start of their automation journey with ABNF, they may opt to use the init command to write out a draft automation configuration file. The init command also accepts the -f file flag to specify an alternate location from the working directory.

The generate command is the way that the automation is invoked. It locates and loads the generation configuration properties from the abnf.yml file. The properties in the configuration file are as follows:

Code Generation Configuration Properties

  • version: must be defined as "1"
  • spec: is the path to the ABNF specification file, e.g. ./testdata/core.abnf
  • gofile: the name of the Go file to generated, e.g. core_abnf.go
  • package: the name of the package for the Go file generated, e.g. core
  • output: the output path where the package (folder) and Go file are written, e.g. .
  • generate: the type of generation, {operators, alternatives}
  • verbose: displays additional debugging information

The generate option either invokes GenerateABNFAsOperators or GenerateABNFAsAlternatives depending on the value of the generate property in the abnf.yml file.

The code is structured to support growth of the configuration file format by including a version property. The code validates the version value when loading the abnf.yml file in config.go.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant