Skip to content

Commit 8d253aa

Browse files
committed
fix: run command
1 parent 4c75ad5 commit 8d253aa

3 files changed

Lines changed: 20 additions & 19 deletions

File tree

.vscode/launch.json

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
],
180180
},
181181
{
182-
"name": "Debug Daemon start",
182+
"name": "Debug Daemon run (touch example)",
183183
"type": "go",
184184
"request": "launch",
185185
"mode": "debug",
@@ -188,21 +188,8 @@
188188
"args": [
189189
"run",
190190
"--cwd",
191-
"${workspaceFolder}/examples/scroll-cwd",
192-
"main.start"
193-
],
194-
},
195-
{
196-
"name": "Debug Daemon run switch scroll",
197-
"type": "go",
198-
"request": "launch",
199-
"mode": "debug",
200-
"program": "${workspaceFolder}/main.go",
201-
"args": [
202-
"run",
203-
"scroll-switch.registry-1.docker.io/highcard/scroll-minecraft-forge:1.20.2",
204-
"--cwd",
205-
"${workspaceFolder}/examples/scroll-cwd",
191+
"${workspaceFolder}/examples/touch",
192+
"start"
206193
],
207194
},
208195
{

cmd/registry_pull.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ var PullCommand = &cobra.Command{
2323

2424
registryClient := registry.NewOciClient(host, user, password)
2525

26-
registryClient.Pull(filepath.Join(cwd, ".scroll"), artifact)
26+
err := registryClient.Pull(filepath.Join(cwd, ".scroll"), artifact)
27+
if err != nil {
28+
logger.Log().Error("Failed to pull from registry")
29+
return err
30+
}
2731

2832
logger.Log().Info("Pulled from registry")
2933
return nil

cmd/run.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/highcard-dev/daemon/internal/utils/logger"
99
"github.com/spf13/cobra"
1010
"github.com/spf13/viper"
11+
"go.uber.org/zap"
1112
)
1213

1314
var RunCmd = &cobra.Command{
@@ -16,6 +17,7 @@ var RunCmd = &cobra.Command{
1617
Args: cobra.ExactArgs(1),
1718
Long: `This command runs a single command from the scroll file.`,
1819
RunE: func(cmd *cobra.Command, args []string) error {
20+
command := args[0]
1921

2022
host := viper.GetString("registry.host")
2123
user := viper.GetString("registry.user")
@@ -63,10 +65,18 @@ var RunCmd = &cobra.Command{
6365
return err
6466
}
6567

66-
command := args[0]
68+
logger.Log().Info("Staring queue")
69+
go queueManager.Work()
6770

71+
logger.Log().Info("Adding command to queue", zap.String("command", command))
6872
err = queueManager.AddTempItem(command)
69-
return err
73+
if err != nil {
74+
return err
75+
}
76+
77+
queueManager.WaitUntilEmpty()
78+
79+
return nil
7080
},
7181
}
7282

0 commit comments

Comments
 (0)