Skip to content

Commit 9530856

Browse files
authored
hypeman exec, ps, pull, run, rm, logs (#5)
* Ignore .env * Generate exec feature * Add docker like aliases * Add rm * Partial ID match and name match * Add support for rm --all * Fix logs
1 parent 2556928 commit 9530856

File tree

14 files changed

+1079
-9
lines changed

14 files changed

+1079
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
dist/
33
/hypeman
44
.env
5+
hypeman/**

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,35 @@ go run cmd/hypeman/main.go
3333

3434
## Usage
3535

36-
The CLI follows a resource-based command structure:
37-
3836
```sh
39-
hypeman [resource] [command] [flags]
40-
```
37+
# Pull an image
38+
hypeman pull nginx:alpine
4139

42-
```sh
43-
hypeman health check
40+
# Run an instance (auto-pulls image if needed)
41+
hypeman run nginx:alpine
42+
hypeman run --name my-app -e PORT=3000 nginx:alpine
43+
44+
# List running instances
45+
hypeman ps
46+
hypeman ps -a # show all instances
47+
48+
# View logs
49+
hypeman logs <instance-id>
50+
hypeman logs -f <instance-id> # follow logs
51+
52+
# Execute a command in a running instance
53+
hypeman exec <instance-id> -- /bin/sh
54+
hypeman exec -it <instance-id> # interactive shell
4455
```
4556

4657
For details about specific commands, use the `--help` flag.
4758

59+
The CLI also provides resource-based commands for more advanced usage:
60+
61+
```sh
62+
hypeman [resource] [command] [flags]
63+
```
64+
4865
## Global Flags
4966

5067
- `--debug` - Enable debug logging (includes HTTP request/response details)

cmd/hypeman/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ import (
1717
func main() {
1818
app := cmd.Command
1919
if err := app.Run(context.Background(), os.Args); err != nil {
20+
// Handle exec exit codes specially - exit with the command's exit code
21+
var execErr *cmd.ExecExitError
22+
if errors.As(err, &execErr) {
23+
os.Exit(execErr.Code)
24+
}
25+
2026
var apierr *hypeman.Error
2127
if errors.As(err, &apierr) {
2228
fmt.Fprintf(os.Stderr, "%s %q: %d %s\n", apierr.Request.Method, apierr.Request.URL, apierr.Response.StatusCode, http.StatusText(apierr.Response.StatusCode))

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ require (
2525
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
2626
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
2727
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
28+
github.com/gorilla/websocket v1.5.3 // indirect
2829
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
2930
github.com/mattn/go-isatty v0.0.20 // indirect
3031
github.com/mattn/go-localereader v0.0.1 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
2424
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2525
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
2626
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
27+
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
28+
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
2729
github.com/itchyny/json2yaml v0.1.4 h1:/pErVOXGG5iTyXHi/QKR4y3uzhLjGTEmmJIy97YT+k8=
2830
github.com/itchyny/json2yaml v0.1.4/go.mod h1:6iudhBZdarpjLFRNj+clWLAkGft+9uCcjAZYXUH9eGI=
2931
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=

pkg/cmd/cmd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ func init() {
6767
},
6868
},
6969
Commands: []*cli.Command{
70+
&execCmd,
71+
&pullCmd,
72+
&runCmd,
73+
&psCmd,
74+
&logsCmd,
75+
&rmCmd,
7076
{
7177
Name: "health",
7278
Category: "API RESOURCE",

0 commit comments

Comments
 (0)