choria-io / appbuilder Goto Github PK
View Code? Open in Web Editor NEWTool to create friendly wrapping command lines over operations tools
License: Apache License 2.0
Tool to create friendly wrapping command lines over operations tools
License: Apache License 2.0
Only show top level commands in top level help output
this will require adopting master of kingpin
I want to be able to use the definition file to do like a makefile type thing. It's not perfect but something we can work towards.
Toward that we should ship a new binary abtask
that when ran wil look for ABTaskFile
locally and .env
for config. Rest should be roughly the same.
See https://choria-io.github.io/appbuilder/experiments/index.html for the current state.
We use CompactMainUsageTemplate
but shoudl be using CompactUsageTemplate
Looks like you created a tag for v0.6.6 but no corresponding release.
This causes the Homebrew recipe to fail because https://github.com/choria-io/appbuilder/releases/download/v0.6.6/appbuilder-0.6.6-darwin-amd64.tar.gz does not exist.
Say you will run some command that might need a ^C at the end and its weird, you might want to print a little warning before starting it. So we should support something like prompt but that doesn't wait
This can be done using https://github.com/benhoyt/goawk which could support CSV/TSV as well
Needs to be able to list apps, show info about source locations etc and validate apps
This helps shell scripts since there's a value rather than just empty
For a custom logger to be used it has to be passed in the log
argument AND the WithLogger()
option, this is redundant
Essentially the CLI from https://github.com/guptarohit/asciigraph without real time data
When a command is known to output YAML or JSON one should be able to attach a gojq transform to it that will take the STDOUT and transform it.
After some experiments scaffold needs a few things:
AppDir
I'm taking a first look at appbuilder on a Macbook Pro running Monterey, I installed with Homebrew.
Following the Quick Start, I put the command definition in ~/.config/appbuilder/demo-app.yaml
, and symlinked applbuilder to ~/bin/demo
.
I got an error message: demo failed: definition not found: demo
Digging around, I discovered the appbuilder info
command, which has the following output
Choria Application Builder
Debug Logging (BUILDER_DEBUG): false
Configuration File (BUILDER_CONFIG): not specified
Definition File (BUILDER_APP): not specified
Source Locations: /Users/robin/Library/Application Support/appbuilder, /etc/appbuilder
I put the command definition in /Users/robin/Library/Application Support/appbuilder
and it works:
$ demo say "it works"
__________
< it works >
----------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
It seems that the source directory ~/.config/appbuilder/
is not checked on MacOS.
I'm not sure if this is a documentation thing or a bug.
Given input like {"x":100}
it will panic because min==max then.
appbuilder/builder/transform_bar_graph.go
Line 90 in 9cd6f85
When a command fail it would be good to support retrying it on a backoff until success. We should log some details during retries and support customizable exit codes indicating success or fail, MVP might just go any !0 is bad though
Instead the left overs from choria are still hard coded
The default fisk template is fine for big apps, but one might want to show the compact view for all sub commands or default kingpin, so I think this should be selectable per app
The file path should be templated and it should support a custom message. By default files should not be overwrote
It would be nice to use the appbuilder framework to embed apps into other fisk commands, or just to compile a app into a binary of its own.
Below we see we mount the app into the root of the cmd
, if this is the getting started cowsay command then you would have:
% go run main.go
usage: testing [<flags>] <command> [<args> ...]
Testing
Commands:
say Say something using the configured command
think Think something using a cow
Pass --help to see global flags applicable to this command.
One can also make a cmd and mount it as a sub easily by just passing a *fisk.CmdClause
instead of *fisk.Application
package main
import (
"context"
_ "embed"
"os"
"github.com/choria-io/appbuilder/builder"
"github.com/choria-io/fisk"
)
//go:embed cowsay.yaml
var def []byte
func main() {
builder.MustRegisterStandardCommands()
cmd := fisk.Newf("testing", "Testing")
err := builder.MountAsCommand(context.TODO(), cmd, def, nil)
if err != nil {
panic(err)
}
cmd.MustParseWithUsage(os.Args[1:])
}
Originally posted by nitrocode June 17, 2022
name: demo
description: demo
author: https://github.com/choria-io/appbuilder
type: parent
commands:
- name: hi
description: hi subcommands
type: parent
commands:
- name: hello
description: hello
type: exec
command: |
echo "world"
echo "hi"
$ demo hi hello
world echo hi
This is incorrect. This should echo world and then echo hi but instead it turns it all into a single line and executes only one command.
Is there a way to run multiple commands using a single command ?
These should be templated.
Imagine we had a histogram transform and jq, we could:
transforms:
- query: .replies.summaries.connected_server
- histogram:
title: Server Connections
width: 20
To take a map[string]int
and turn it into a histogram with that title thats 20 chars wide
Fisk.next will have native support for cheats, we should support adding them to commands
only map[string]any
but []any
is also valid json, so we need to marshal into interface{}
not map[string]interface{}
appbuilder/builder/transform_jq.go
Line 55 in 3634c37
$ sample basics confirm
? Are you sure you wish to execute the command Yes
>>>
>>> This command is potentially destructive and should only
>>> be run during maintenance windows.
>>>
execution confirmed, will run command
You should be able to use the banner to tell people why you're prompting etc
I think we'd need a repo to host homebrew things also
We should be able to scaffold many files using a command in a Tasfile, flags, arguments and other relavant details like working dir and app dir should be set as context and all files should be template parsed
name: scaffold
description: Creates an skeleton thing
arguments:
- name: name
description: The directory to create
required: true
type: scaffold
# required, should not exist
target: /tmp/{{ .Arguments.Name }}
# where to find a directory full of files to base the scaffold from, supports templates
source_directory: /..../scaffold.source
# for smaller use cases one can instead specify the source in yaml here (ugh)
source:
x.txt: |
Content here ....
foo: # a directory called foo with a file in it
bar.txt: |
Content here ...
# Post processes files matching with filepath.Match using shell commands
# if {} is in the string its replaced with path, if not path is appended as argument
post:
- "*.go": gofmt -w {}
- "*.go": goimports -w
We should allow incoming JSON data to be transformed using a template into text - optionally to a file. The template should also be read from a file or inline.
Should embed http://masterminds.github.io/sprig/
Just like we have choria completion --zsh
/ choria completion --bash
, it would be handy to have a similar way to generate completions with appbuilder.
Should run various app definitions and assert the outcome is sane
Today we support loading data from files, this mean the files has to be on every machine.
It would be good to support other modes at least in concept. Another tool like go-choria that embeds this might supply a config loader / app loader that uses the Choria KV as a source.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.