Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main // import "github.com/tianon/gosu"

import (
"bytes"
"fmt"
"log"
"os"
Expand All @@ -10,7 +9,6 @@ import (
"runtime"
"strings"
"syscall"
"text/template"
)

func init() {
Expand All @@ -24,24 +22,18 @@ func version() string {
}

func usage() string {
t := template.Must(template.New("usage").Parse(`
t := `
Usage: {{ .Self }} user-spec command [args]
eg: {{ .Self }} tianon bash
{{ .Self }} nobody:root bash -c 'whoami && id'
{{ .Self }} 1000:1 id

{{ .Self }} version: {{ .Version }}
{{ .Self }} license: Apache-2.0 (full text at https://github.com/tianon/gosu)
`))
var b bytes.Buffer
template.Must(t, t.Execute(&b, struct {
Self string
Version string
}{
Self: filepath.Base(os.Args[0]),
Version: version(),
}))
return strings.TrimSpace(b.String()) + "\n"
`
t = strings.ReplaceAll(t, "{{ .Self }}", filepath.Base(os.Args[0]))
t = strings.ReplaceAll(t, "{{ .Version }}", version())
return t[1:]
}

func main() {
Expand Down