Skip to content

Commit

Permalink
export clean_swift_scaffold pkg with runner command
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekTree0101 committed Aug 18, 2021
1 parent 0de04bc commit 1e94366
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 65 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Go](https://github.com/GeekTree0101/clean-swift-scaffold/actions/workflows/go.yml/badge.svg?branch=develop)](https://github.com/GeekTree0101/clean-swift-scaffold/actions/workflows/go.yml)


### How to use?
### Basic Usage

<img height=300pt src="https://github.com/GeekTree0101/clean-swift-scaffold/blob/develop/res/example.png" />

Expand All @@ -19,9 +19,29 @@ test_path: ./Playground/Tests // base test file destination
indentation: 2 // indentation
```
#### add clean_swift_scaffold runner command on your command
```go
var rootCmd = &cobra.Command{
Use: "your cmd",
Short: "your cmd short marty",
Long: "your cmd long something",
}

init() {
rootCmd.AddCommand(clean_swift_scaffold.NewRunnerCommand("**use_name**"))
}

func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
```

#### run
```sh
clean-swift-scaffold run -n Feed -u Fetch,Delete,Update
your_command **use_name** -n Feed -u Fetch,Delete,Update
```

flag list
Expand Down
22 changes: 0 additions & 22 deletions cmd/logo.go

This file was deleted.

21 changes: 0 additions & 21 deletions cmd/root.go

This file was deleted.

8 changes: 0 additions & 8 deletions main.go

This file was deleted.

46 changes: 34 additions & 12 deletions cmd/gen.go → runner.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cmd
package clean_swift_scaffold

import (
"fmt"
Expand All @@ -7,9 +7,37 @@ import (
"github.com/spf13/cobra"
)

var (
genCmd = &cobra.Command{
Use: "run",
const (
logo = `
_____ _ _____ _ __ _
/ __ \ | / ___| (_)/ _| |
| / \/ | ___ __ _ _ __ \ '--.__ ___| |_| |_
| | | |/ _ \/ _' | '_ \ '--. \ \ /\ / / | _| __|
| \__/\ | __/ (_| | | | /\__/ /\ V V /| | | | |_
\____/_|\___|\__,_|_| |_\____/ \_/\_/ |_|_| \__|
_____ __ __ _ _
/ ___| / _|/ _| | | | |
\ '--. ___ __ _| |_| |_ ___ | | __| |
'--. \/ __/ _' | _| _/ _ \| |/ _' |
/\__/ / (_| (_| | | | || (_) | | (_| |
\____/ \___\__,_|_| |_| \___/|_|\__._|
Copyright © 2021 Geektree0101. All rights reserved.
`
)

func NewRunnerCommand(use string) *cobra.Command {

var name string
var usecasesString string
var sourceDir string
var testDir string
var configFilePath string

genCmd := &cobra.Command{
Use: use,
Short: "generate source & unit tests files",
Run: func(cmd *cobra.Command, args []string) {

Expand Down Expand Up @@ -40,19 +68,13 @@ var (

},
}
name string
usecasesString string
sourceDir string
testDir string
configFilePath string
)

func init() {
genCmd.Flags().StringVarP(&name, "name", "n", "", "Usecase name, ex: -n Detail or --name Detail")
genCmd.Flags().StringVarP(&usecasesString, "usecases", "u", "", "Behavior names, ex: -u Reload,Next or --usecases Reload,Next")
genCmd.Flags().StringVarP(&configFilePath, "config", "c", "./config.yaml", "Configure file path, ex: -t ./some/config.yaml or --test ./some/config.yaml")
// optional flags
genCmd.Flags().StringVarP(&sourceDir, "source", "s", "", "Source dir, ex: -s ./Projects or --source ./Projects")
genCmd.Flags().StringVarP(&testDir, "test", "t", "", "Test dir, ex: -t ./Projects or --test ./Projects")
rootCmd.AddCommand(genCmd)

return genCmd
}

0 comments on commit 1e94366

Please sign in to comment.