Files
dagu/internal/cmd/command_scope.go

33 lines
935 B
Go

// Copyright (C) 2026 Yota Hamada
// SPDX-License-Identifier: GPL-3.0-or-later
package cmd
import "strings"
type commandScope string
const (
commandScopeContextAware commandScope = "context-aware"
commandScopeLocalOnly commandScope = "local-only"
commandScopeStatic commandScope = "static"
)
func scopeForCommand(name string) commandScope {
// Every connection subcommand calls the server's REST API.
if name == "connection" || strings.HasPrefix(name, "connection ") {
return commandScopeContextAware
}
switch name {
case "start", "enqueue", "status", "history", "stop", "retry", "restart", "dequeue",
"nodes list", "nodes show", "nodes add", "nodes remove", "nodes forget", "nodes test", "nodes import", "nodes export":
return commandScopeContextAware
case "version", "schema", "xlsx":
return commandScopeStatic
case "context":
return commandScopeStatic
default:
return commandScopeLocalOnly
}
}