QBitRun/cmd/qbitrun/main.go
2024-06-25 00:19:15 +07:00

53 lines
1.5 KiB
Go

package main
import (
"context"
"os"
"os/signal"
"github.com/tigorlazuardi/qbitrun/cmd/qbitrun/cli"
)
var (
Build string = "v0.0.0"
// LookUpMode should be handled by LDFlags (subject to change) or perhaps ENV (or both).
//
// This behavior will determine where to look up workflow files.
//
// XDG mode will be bad for standalone binary, as users is expected to put
// their workflow dir next to the executable itself.
//
// Packaged mode where the exe is in normally unreachable location for runtime files (e.g. /usr/bin)
// will expect users to put their workflow files in XDG dirs.
//
// Others probably wants where the CWD contains the workflow dir.
//
// All of this is supllanted by the --workflow-dir flag though.
// So Users should be told to use that for consistent behavior
// or when using multiple qBittorrent instances and want
// to use different workflow dirs.
//
// Expected values:
// - "xdg": look up in XDG_CONFIG_HOME/qbitrun/workflows
// - "cwd": look up workflows dir in the current working directory
// - other: look up workflows dir in the same directory as the executable
//
// NOTE:
// Unlike config files, layered heuristics is probably not a good idea since User
// does not expect workflow files to be looked up in different places and merged.
LookUpMode string = "exe"
)
func main() {
cli.Version = Build
cli.LookUpMode = LookUpMode
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()
if err := cli.RootCmd.ExecuteContext(ctx); err != nil {
os.Exit(1)
}
}