Add initial implementation of member-console application with basic commands
This commit is contained in:
54
cmd/init.go
Normal file
54
cmd/init.go
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright © 2025 Wiki Cafe <mail@wiki.cafe>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// initCmd represents the init command
|
||||
var initCmd = &cobra.Command{
|
||||
Use: "init [path]",
|
||||
Short: "Create the directory structure needed for the member-console",
|
||||
Long: `The init command creates the directory structure and files needed for the
|
||||
member-console web application in the current directory.
|
||||
|
||||
A different directory can be specified using the --dir flag.`,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("init called")
|
||||
|
||||
// Create the directories and files needed for the member-console web application in the
|
||||
targetDir := args[0]
|
||||
componentsDir := filepath.Join(targetDir, "components")
|
||||
|
||||
if err := os.MkdirAll(componentsDir, 0755); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error creating components directory: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Project initialized at %s\n", targetDir)
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(initCmd)
|
||||
}
|
Reference in New Issue
Block a user