55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
/*
|
|
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)
|
|
}
|