mirror of
https://github.com/dagucloud/dagu.git
synced 2026-12-05 21:34:48 +00:00
33 lines
935 B
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
|
|
}
|
|
}
|