mirror of https://github.com/Xhofe/alist
feat: export all cmd (#2746)
parent
6024e8d832
commit
0ae3fc608b
|
@ -9,8 +9,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// passwordCmd represents the password command
|
// PasswordCmd represents the password command
|
||||||
var passwordCmd = &cobra.Command{
|
var PasswordCmd = &cobra.Command{
|
||||||
Use: "admin",
|
Use: "admin",
|
||||||
Aliases: []string{"password"},
|
Aliases: []string{"password"},
|
||||||
Short: "Show admin user's info",
|
Short: "Show admin user's info",
|
||||||
|
@ -26,7 +26,7 @@ var passwordCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(passwordCmd)
|
RootCmd.AddCommand(PasswordCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
// Here you will define your flags and configuration settings.
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// cancel2FACmd represents the delete2fa command
|
// Cancel2FACmd represents the delete2fa command
|
||||||
var cancel2FACmd = &cobra.Command{
|
var Cancel2FACmd = &cobra.Command{
|
||||||
Use: "cancel2fa",
|
Use: "cancel2fa",
|
||||||
Short: "Delete 2FA of admin user",
|
Short: "Delete 2FA of admin user",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
@ -28,7 +28,7 @@ var cancel2FACmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(cancel2FACmd)
|
RootCmd.AddCommand(Cancel2FACmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
// Here you will define your flags and configuration settings.
|
||||||
|
|
||||||
|
|
|
@ -123,8 +123,8 @@ func generateSettingsJson() {
|
||||||
//utils.WriteJsonToFile("lang/settings.json", settingsLang)
|
//utils.WriteJsonToFile("lang/settings.json", settingsLang)
|
||||||
}
|
}
|
||||||
|
|
||||||
// langCmd represents the lang command
|
// LangCmd represents the lang command
|
||||||
var langCmd = &cobra.Command{
|
var LangCmd = &cobra.Command{
|
||||||
Use: "lang",
|
Use: "lang",
|
||||||
Short: "Generate language json file",
|
Short: "Generate language json file",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
@ -138,7 +138,7 @@ var langCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(langCmd)
|
RootCmd.AddCommand(LangCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
// Here you will define your flags and configuration settings.
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// restartCmd represents the restart command
|
// RestartCmd represents the restart command
|
||||||
var restartCmd = &cobra.Command{
|
var RestartCmd = &cobra.Command{
|
||||||
Use: "restart",
|
Use: "restart",
|
||||||
Short: "Restart alist server by daemon/pid file",
|
Short: "Restart alist server by daemon/pid file",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
@ -18,7 +18,7 @@ var restartCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(restartCmd)
|
RootCmd.AddCommand(RestartCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
// Here you will define your flags and configuration settings.
|
||||||
|
|
||||||
|
|
14
cmd/root.go
14
cmd/root.go
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var RootCmd = &cobra.Command{
|
||||||
Use: "alist",
|
Use: "alist",
|
||||||
Short: "A file list program that supports multiple storage.",
|
Short: "A file list program that supports multiple storage.",
|
||||||
Long: `A file list program that supports multiple storage,
|
Long: `A file list program that supports multiple storage,
|
||||||
|
@ -17,16 +17,16 @@ Complete documentation is available at https://alist.nn.ci/`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func Execute() {
|
func Execute() {
|
||||||
if err := rootCmd.Execute(); err != nil {
|
if err := RootCmd.Execute(); err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.PersistentFlags().StringVar(&flags.DataDir, "data", "data", "config file")
|
RootCmd.PersistentFlags().StringVar(&flags.DataDir, "data", "data", "config file")
|
||||||
rootCmd.PersistentFlags().BoolVar(&flags.Debug, "debug", false, "start with debug mode")
|
RootCmd.PersistentFlags().BoolVar(&flags.Debug, "debug", false, "start with debug mode")
|
||||||
rootCmd.PersistentFlags().BoolVar(&flags.NoPrefix, "no-prefix", false, "disable env prefix")
|
RootCmd.PersistentFlags().BoolVar(&flags.NoPrefix, "no-prefix", false, "disable env prefix")
|
||||||
rootCmd.PersistentFlags().BoolVar(&flags.Dev, "dev", false, "start with dev mode")
|
RootCmd.PersistentFlags().BoolVar(&flags.Dev, "dev", false, "start with dev mode")
|
||||||
rootCmd.PersistentFlags().BoolVar(&flags.ForceBinDir, "force-bin-dir", false, "Force to use the directory where the binary file is located as data directory")
|
RootCmd.PersistentFlags().BoolVar(&flags.ForceBinDir, "force-bin-dir", false, "Force to use the directory where the binary file is located as data directory")
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// serverCmd represents the server command
|
// ServerCmd represents the server command
|
||||||
var serverCmd = &cobra.Command{
|
var ServerCmd = &cobra.Command{
|
||||||
Use: "server",
|
Use: "server",
|
||||||
Short: "Start the server at the specified address",
|
Short: "Start the server at the specified address",
|
||||||
Long: `Start the server at the specified address
|
Long: `Start the server at the specified address
|
||||||
|
@ -76,7 +76,7 @@ the address is defined in config file`,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(serverCmd)
|
RootCmd.AddCommand(ServerCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
// Here you will define your flags and configuration settings.
|
||||||
|
|
||||||
|
@ -95,5 +95,5 @@ func OutAlistInit() {
|
||||||
cmd *cobra.Command
|
cmd *cobra.Command
|
||||||
args []string
|
args []string
|
||||||
)
|
)
|
||||||
serverCmd.Run(cmd, args)
|
ServerCmd.Run(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// startCmd represents the start command
|
// StartCmd represents the start command
|
||||||
var startCmd = &cobra.Command{
|
var StartCmd = &cobra.Command{
|
||||||
Use: "start",
|
Use: "start",
|
||||||
Short: "Silent start alist server with `--force-bin-dir`",
|
Short: "Silent start alist server with `--force-bin-dir`",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
@ -57,7 +57,7 @@ func start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(startCmd)
|
RootCmd.AddCommand(StartCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
// Here you will define your flags and configuration settings.
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// stopCmd represents the stop command
|
// StopCmd represents the stop command
|
||||||
var stopCmd = &cobra.Command{
|
var StopCmd = &cobra.Command{
|
||||||
Use: "stop",
|
Use: "stop",
|
||||||
Short: "Stop alist server by daemon/pid file",
|
Short: "Stop alist server by daemon/pid file",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
@ -44,7 +44,7 @@ func stop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(stopCmd)
|
RootCmd.AddCommand(StopCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
// Here you will define your flags and configuration settings.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
|
@ -12,8 +11,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
// versionCmd represents the version command
|
// VersionCmd represents the version command
|
||||||
var versionCmd = &cobra.Command{
|
var VersionCmd = &cobra.Command{
|
||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Show current version of AList",
|
Short: "Show current version of AList",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
@ -30,7 +29,7 @@ WebVersion: %s
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(versionCmd)
|
RootCmd.AddCommand(VersionCmd)
|
||||||
|
|
||||||
// Here you will define your flags and configuration settings.
|
// Here you will define your flags and configuration settings.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue