Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pkg/sandbox/runx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
29 changes: 24 additions & 5 deletions pkg/sandbox/runx/cmd/runx/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"context"
"flag"
"fmt"
"os"

Expand All @@ -13,7 +14,10 @@ func Help() {
c := color.New(color.FgCyan).Add(color.Underline)
c.Println("runx")
fmt.Println()
fmt.Println("Usage: runx [+<org>/<repo>]... [<cmd>] [<args>]...")
fmt.Println(
"Usage: runx [+<org>/<repo>]... [<cmd>] [<args>]...",
"Usage: runx --install [<org>/<repo>]...",
)
}

func Execute(ctx context.Context, args []string) int {
Expand All @@ -22,11 +26,26 @@ func Execute(ctx context.Context, args []string) int {
return 0
}

err := runx.Run(args...)
if err != nil {
fmt.Fprintf(os.Stderr, "[ERROR] %s\n", err)
return 1
install := flag.Bool("install", false, "install packages only")
flag.Parse()

if *install {
paths, err := runx.Install(args[1:]...)
if err != nil {
fmt.Fprintf(os.Stderr, "[ERROR] %s\n", err)
return 1
}
fmt.Println("Installed paths:")
for _, path := range paths {
fmt.Printf(" %s\n", path)
}
} else {
if err := runx.Run(args...); err != nil {
fmt.Fprintf(os.Stderr, "[ERROR] %s\n", err)
return 1
}
}

return 0
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/sandbox/runx/devbox.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"packages": [
"go@latest"
],
"shell": {
"scripts": {
"build": "go build -o dist/runx cmd/runx/main.go"
}
}
}
25 changes: 25 additions & 0 deletions pkg/sandbox/runx/devbox.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"lockfile_version": "1",
"packages": {
"go@latest": {
"last_modified": "2023-09-17T10:54:49Z",
"resolved": "github:NixOS/nixpkgs/5148520bfab61f99fd25fb9ff7bfbb50dad3c9db#go_1_21",
"source": "devbox-search",
"version": "1.21.1",
"systems": {
"aarch64-darwin": {
"store_path": "/nix/store/jkhg33806wygpwpix47d2h5scfgn01i8-go-1.21.1"
},
"aarch64-linux": {
"store_path": "/nix/store/sgkkfw6saficch0mviqyqyw6nj64kzf9-go-1.21.1"
},
"x86_64-darwin": {
"store_path": "/nix/store/w67nj5iqgnz0msi8i12kyh9nhsp2ci9n-go-1.21.1"
},
"x86_64-linux": {
"store_path": "/nix/store/jk0bqfsjijia52vks1wxqnn4s6dxaiqp-go-1.21.1"
}
}
}
}
}
7 changes: 4 additions & 3 deletions pkg/sandbox/runx/runx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"go.jetpack.io/pkg/sandbox/runx/impl"
)

func Install(pkgs ...string) error {
_, err := impl.Install(pkgs...)
return err
// Install installs the given packages and returns the paths to the directories
// where they were installed.
func Install(pkgs ...string) ([]string, error) {
return impl.Install(pkgs...)
}

func Run(args ...string) error {
Expand Down