Giter Club home page Giter Club logo

rwxrob / bonzai Goto Github PK

View Code? Open in Web Editor NEW
150.0 7.0 16.0 516 KB

🌳 Go Bonzai™ Composite Commander, meticulously manicured monolith and multicall binaries, built from imported composite commands, on any device, with recursive, light-weight tab completion, and colorful embedded documentation from terminal or local web browser. Replace messy collections of shell scripts ported to clean Go.

License: Apache License 2.0

Go 100.00%
cli commander cobra help documentation golang terminal composition busybox bonzai

bonzai's Introduction

🌳 Go Bonzai™ Command Compositor

GoDoc License Go Report Card

"It's like a modular, multicall BusyBox builder for Go with built in completion and embedded documentation support."

"The utility here is that Bonzai lets you maintain your own personal 'toolbox' with built in auto-complete that you can assemble from various Go modules. Individual commands are isolated and unaware of each other and possibly maintained by other people."

"I used Bonzai for a pentest ... was able to inject ebpf.io kernel modules that were part of bin lol! Bonzai is Genius!"

logo

Bonzai was born from a very real need to replace messy collections of shell scripts, wasteful completion sourcing, and OS-specific documentation with a single, stateful, binary composed of commands organized as rooted node trees with a clean, modular, portable, statically-compiled, and dynamically self-documenting design.

There's no better language than Go for such things.

Bonzai gets its name from the fact that Bonzai users are fond of meticulously manicuring their own stateful command trees, built from imported composite commands that they can easily copy and run on on any device, anywhere.

Bonzai users can easily share their own commands with others just like they would any other Go module and since any Bonzai command also doubles as a high-level library package, even non-Bonzai users benefit.

Most realize Bonzai really distinguishes itself from anything else out there the first time they turn any command branch into a fully-documented, tab-completing, stand-alone binary simply by wrapping it in five lines of code. Such is the beauty of stateful command tree design. There's simply nothing else like it, in Go or any other language.

Getting Started

Read the book:

Copy or clone the example template:

Get ideas for your own by looking at others

Legal

Copyright 2022 Robert S. Muhlestein (mailto:[email protected])
SPDX-License-Identifier: Apache-2.0

"Bonzai" and "bonzai" are legal trademarks of Robert S. Muhlestein but can be used freely to refer to the Bonzai™ project https://github.com/rwxrob/bonzai without limitation. To avoid potential developer confusion, intentionally using these trademarks to refer to other projects --- free or proprietary --- is prohibited.

bonzai's People

Contributors

pandoxer avatar rwxrob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bonzai's Issues

Add 1.18 fuzzy tests to Parse tests

Need to setup re-creatable fuzzers for anything that has a set of any
kind. For example, is.WS has quite a few different combinations.
Something like scan.Expect(is.Opt{is.WS},"foo",is.Opt{is.WS}) has
several hundred possible combinations.

Change default import name to Z

Since Bonzai's focus is on rapid development and clean code I'm making
the default import package name Z (instead of bonzai). The likelihood
of people having package naming conflicts with a capital Z is very
unlikely and anything that does can set the prefix to something else.
Basically, I want the default to be as easy to use as possible. Go
formalists will scream at me for this, but I don't give a fuck.

Change maps package to only contain map functions

We want to reserve the maps subpackage for nothing but map functions so
people can peruse it for map functions they might need and not want to
rewrite. This also gives a good overview of how to use map functions.
Anything that is not a map function should find another home.

Prevent repeating final completions

After reaching the leaf completion continually tapping tab keeps adding
the last completion leaf item to the end of the command line. We need to
trap this from happening.

Add Cmd.AutoUpdate

Should look at Version detect an VERSION file within the Source URL
location making intelligent decisions about the Source URL expansion
required by the hosting service (github.com, for example). If not
VERSION file is found and the service is github.com use the GitHub API
to determine the latest release. It is important that there be no
dependency on Git for checking for a latest version allowing
distribution of binaries to take place on a simple web server with a
VERSION file next to the binaries.

Add main alias shell escaping

When tab completion happens the ! characters and such need to be
escaped. But this will depend on the shell environment, but since
COMP_LINE will never be set for anything but bash we are good to assume
it.

We need a bonzai.mark parser and AST handler

Since documentation is a core value proposition from Bonzai, we need to
really create a formal specification (PEGN), parser, and AST for the
unique (but compatible) bonzai.mark language. Creating an AST is
essential for Cmd creators who want to create views of the documentation
in other formats besides text, such as from a local web server.

Add standard compiled util testing

Go has no standardized way to test the compiled commands (focusing
instead on functions and methods). While this is fine for most
applications development, Bonzai developers have a consistent need to
test every possible command line invocation or their final commands
(post compilation). The usual tricks to get os.Args[0] and run that
seem clunky and inconsistent. Something more is needed.

The need for a custom solution is increased when considering that
examples of command line usage are a fundamental part of the
documentation and regularly are buggy in the docs. So any test solution
must incorporate the ability to embed the runnable tests into the
compiled binary so that they are available with foo help examples.

In fact, why not give them unique names and allow the examples to be run
from the command line by adding run after the name (foo help example bar run).

Add `cmd.Shell`

The cmd.Shell should create a rich-terminal interactive shell that
contains help information and a prompt with tab completion. This will
ease the pain of using Bonzai commands where complete -C foo foo
support is not enabled (including inferior shells like zsh, fish,
powershell).

Add embedded help examples generated from example tests

Examples are the most important part of the documentation and they
already have to be created as unit tests anyway. So we need to create a
generator directive that grabs them from the examples_test.go files
when the command is compiled and embedded. In fact, we can simple embed
the examples_test.go file itself and add the code to cmd.Help to
open it and parse the essential parts of it and transform it exactly as
the unit test reflection method uses.

Refactor Expect completely into methods (no recursion)

At long last I've seen the light. It was always grating on me that
Expected used so much unnecessary functional recursion. Using simple
scanner methods that panic is easier to write and maintain, faster,
cleaner, and just as easy to generate from PEGN. I'll still keep the
one-to-one parity with PEGN and read a comment to associate a given
method with a specific ID from PEGN. First I'll factor into methods,
then I'll write the method generator, then we'll write the reverse to
PEGN generator.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.