Skip to content

Commit b6b9d4d

Browse files
authored
add root to command tree, touch up docs (#115)
* add root to command tree, touch up docs * add opengraph image to docs
1 parent e12052a commit b6b9d4d

File tree

17 files changed

+42
-19
lines changed

17 files changed

+42
-19
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
blank_issues_enabled: true
2-
# contact_links:
3-
# - name: Twitter
4-
# url: https://twitter.com/unRob
5-
# about: Got thoughts and a twitter account?
2+
contact_links:
3+
- name: Docs
4+
url: https://milpa.dev/
5+
about: Documentation on using `milpa`
6+
- name: Fediverse
7+
url: https://club.pati.to/@rob
8+
about: Got thoughts and a twitter account?
9+
- name: Twitter
10+
url: https://twitter.com/unRob
11+
about: Got thoughts and a twitter account?
612

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ compa
33
dist
44
test/coverage.*
55
test/coverage
6+
!.milpa

.milpa/commands/itself/command-tree.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
summary: Prints a tree of known commands
22
description: |
3-
Prints out command names and descriptions, or optionally a nested representation of all properties of commands, serialized as `json` or `yaml`. Custom textual representations of commands can be obtained by using the `--template` option and specifying a [go-template](https://pkg.go.dev/text/template#hdr-Actions) to be applied to every command. See [chinampa/pkg.Command](https://pkg.go.dev/git.rob.mx/nidito/chinampa@v0.0.0-20230324015136-6ec1c56f0fc5/pkg/command#Command) and [milpa/internal/command.Meta](https://pkg.go.dev/github.com/unrob/milpa@v0.0.0-20230321064607-ee1825c67af7/internal/command#Meta) for references on the structs available during template rendering.
3+
Prints out command names and descriptions, or optionally a nested representation of all properties of commands, serialized as `json` or `yaml`. Custom textual representations of commands can be obtained by using the `--template` option and specifying a [go-template](https://pkg.go.dev/text/template#hdr-Actions) to be applied to every command. See [chinampa/pkg.Command](https://pkg.go.dev/git.rob.mx/nidito/chinampa/pkg/command#Command) and [milpa/internal/command.Meta](https://pkg.go.dev/github.com/unrob/milpa/internal/command#Meta) for references on the structs available during template rendering.
44
55
## Examples
66

.milpa/docs/milpa/support.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ description: how to deal with bugs in milpa
44
weight: 99
55
---
66

7-
`milpa` is currently alpha software. This means that while I've personally tested it for over a year:
8-
9-
- test coverage is pretty lacking,
10-
- the command spec and script environment is subject to change, and,
11-
- there's **no guarantee of stability** of any internal command or utility.
7+
`milpa` is currently beta software: the tool is mostly feature-complete, but these features are likely to contain bugs, not be properly covered by the test suite nor fully documented. Bug reports, code contributions and general questions are welcome!
128

139
## ℹ️ Requesting help
1410

15-
Please [open a support request](https://github.com/unRob/milpa/issues/new?assignees=&labels=help-requested&template=help-request.yml&title=%5Bhelp%5D%3A+) on github, and I'll do my best to help.
11+
Please [open a support request](https://github.com/unRob/milpa/issues/new?assignees=&labels=help-requested&template=help-request.yml&title=%5Bhelp%5D%3A+) on Github, and I'll do my best to help.
1612

1713

1814
## 🐛 Reporting bugs

.milpa/docs/milpa/use-case.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ My goal with `milpa` is to make following the [Command Line Interface Guidelines
2222

2323
Tasks like bootstrapping development environments are usually left out for the user to accomplish by following through a README or wiki with likely outdated links; `milpa` is great when these tasks can be accomplished by prompting for information, querying identity providers and then running configuration commands or modifying the filesystem directly.
2424

25-
> ⚠️ `milpa` is still under development and is currently on alpha!
25+
> ⚠️ `milpa` is still under development and is currently on beta!
2626
2727
### Examples
2828

2929
Here's some examples of how I've used used `milpa` so far:
3030

3131
- for **managing homelab services** (i.e. [unRob/nidito](https://github.com/unRob/nidito/tree/master/.milpa)): building and deploying them, looking at their status and logs. From my personal device or CI.
32-
- **bootstrapping engineering laptops** (i.e. [unRob/dotfiles](https://github.com/unRob/dotfiles/tree/master/.milpa/commands/computar)): no need to follow a README, you get the right development environment for your os/arch, your credentials setup and the code ready for you to dive in.
32+
- **bootstrapping workstations** (i.e. [unRob/dotfiles](https://github.com/unRob/dotfiles/tree/master/.milpa/commands/computar)): no need to follow a README, you get the right development environment for your os/arch, your credentials setup and the code ready for you to dive in.
3333
- **every-day dev workflow** (i.e. [unRob/milpa](https://github.com/unRob/milpa/tree/main/repos/internal/commands/)): lint and test a codebase, connect to vpn, get credentials to resources, maybe `--connect` to them, abstract away APIs (internal, cloud provider and SaaS) and CLIs, toggle feature gates, build reports and update google sheets with the results.
3434
- as a way to organize all those odd, one-off-but-not-really commands: found a nice home for [shell scripts](https://github.com/unRob/dotfiles/blob/master/.milpa/commands/code/todo.sh), quick ruby scripts, perl hacks and [jq monstrosities](https://github.com/unRob/dotfiles/blob/master/.milpa/commands/creds.sh) that used to live in my `~/.zsh_history`.
3535

@@ -77,7 +77,7 @@ That being said, organizing makefiles and dealing with arguments is not somethin
7777

7878
### BYOCLI
7979

80-
Building your own CLI is usually what ends up happening given a team with enough time and direction to invest in building a proper CLI with whatever language is already at use. Some teams use more than one language, which may complicate this approach. In the microservices world, many codebases come with their own CLIs that may follow slightly different conventions, are seldomly documented and often just end up calling other binaries through `exec`.
80+
Building your own CLI is usually what ends up happening given a team with enough time and direction to invest in building a proper CLI with whatever language is already at use. Some teams use more than one language, which may complicate this approach. In the micro-services world, many codebases come with their own CLIs that may follow slightly different conventions, are seldomly documented and often just end up calling other binaries through `exec`.
8181

8282
In my limited experience with engineering teams of less than 300 folks, many of the bootstrapping tasks will involve operations that can easily (and more succinctly) be expressed with a shell scripting language. `milpa` could also be a useful intermediate step, that could help teams avoid the dread of confluence/notion/google-docs runbooks until it's a good time to build your own CLI.
8383

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ For a brief introductory tutorial, check out [`milpa help docs milpa quick-guide
77
```sh
88
# install on mac and linux with:
99
curl -L https://milpa.dev/install.sh | bash -
10+
# or with homebrew
11+
brew install unRob/formulas/milpa
1012
```
1113

1214
You and your team write scripts and a little spec for each of them—use bash, or any other language—, and `milpa` provides:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/unrob/milpa
33
go 1.20
44

55
require (
6-
git.rob.mx/nidito/chinampa v0.1.3
6+
git.rob.mx/nidito/chinampa v0.1.4
77
github.com/alecthomas/chroma/v2 v2.9.1
88
github.com/alessio/shellescape v1.4.2
99
github.com/bmatcuk/doublestar/v4 v4.6.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
git.rob.mx/nidito/chinampa v0.1.3 h1:ZzOZLHZo5g0xKpWW0PM6MrX1dnvzYEQB2V7JZgwTstc=
2-
git.rob.mx/nidito/chinampa v0.1.3/go.mod h1:isI138ZQ3GN/ZcuRrNPJ48fYnPC+U642gUe5bonhwUo=
1+
git.rob.mx/nidito/chinampa v0.1.4 h1:rXmtuwYNtBmpLgWnNK7b5Z/styyuFfCP3RqL+qOzlok=
2+
git.rob.mx/nidito/chinampa v0.1.4/go.mod h1:isI138ZQ3GN/ZcuRrNPJ48fYnPC+U642gUe5bonhwUo=
33
github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink=
44
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
55
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=

internal/actions/command_tree.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ func addMetaToTree(t *tree.CommandTree) {
3333
Kind: milpaCmd.KindVirtual,
3434
}
3535
t.Command.Meta = &meta
36+
if t.Command.Path[0] != "milpa" {
37+
t.Command.Path = append([]string{"milpa"}, t.Command.Path...)
38+
}
3639
}
3740

3841
for _, subT := range t.Children {
@@ -130,6 +133,9 @@ var CommandTree = &command.Command{
130133
tree := t.(*tree.CommandTree)
131134
addMetaToTree(tree)
132135
var output bytes.Buffer
136+
if err := tpl.Execute(&output, tree.Command); err != nil {
137+
return output.Bytes(), err
138+
}
133139
err := tree.Traverse(func(cmd *command.Command) error { return tpl.Execute(&output, cmd) })
134140
return output.Bytes(), err
135141
}

internal/command/meta.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,23 @@ func metaForPath(path string, repo string) (meta Meta) {
3535
var name string
3636
if strings.HasSuffix(path, ".yaml") {
3737
name = filepath.Dir(path)
38-
name = strings.TrimPrefix(name, repo+"/"+_c.RepoCommandFolderName+"/")
38+
name = strings.TrimPrefix(name, repo+"/")
39+
name = strings.TrimPrefix(name, _c.RepoCommandFolderName+"/")
3940
meta.Path = name
4041
meta.Kind = KindVirtual
4142
} else {
4243
meta.Path = path
4344
name = strings.TrimSuffix(path, ".sh")
44-
name = strings.TrimPrefix(name, repo+"/"+_c.RepoCommandFolderName+"/")
45+
name = strings.TrimPrefix(name, repo+"/")
46+
name = strings.TrimPrefix(name, _c.RepoCommandFolderName+"/")
4547

4648
if strings.HasSuffix(path, ".sh") {
4749
meta.Kind = KindSource
4850
} else {
4951
meta.Kind = KindExecutable
5052
}
5153
}
54+
5255
meta.Repo = repo
5356
meta.Name = strings.Split(name, "/")
5457
meta.issues = []error{}

0 commit comments

Comments
 (0)