Skip to content

Commit

Permalink
Feat: add resourcesList return array and log the return in cli func
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthis Holleville committed Mar 27, 2020
1 parent 513d0cb commit 9e29dc6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 5 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"fmt"
"github.com/otiai10/copy"
"io/ioutil"
"log"
Expand All @@ -16,15 +15,18 @@ func InitProject(projectType string, projectName string){
}
}

func ResourcesList(){
func ResourcesList() []string {
var modules []string
files, err := ioutil.ReadDir(rootProjectPath() + "/resources")
if err != nil {
log.Fatal(err)
}

for _, f := range files {
if f.IsDir() {
fmt.Println(f.Name())
modules = append(modules, f.Name())
}
}

return modules
}
16 changes: 15 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main

import (
"fmt"
"github.com/urfave/cli"
"log"
"os"
"strings"
)

var App = cli.NewApp()
Expand Down Expand Up @@ -34,6 +36,16 @@ func info() {
App.Version = "0.0.1"
}

func configureCommand(name string) cli.Command {
return cli.Command{
Name: "configure",
Usage: "configure " + name,
Action: func(c *cli.Context) {
println("configuring " + name)
},
}
}

func commands() {
App.Commands = []cli.Command{
{
Expand Down Expand Up @@ -126,7 +138,9 @@ func commands() {
Name: "list",
Usage: "options for project init",
Action: func(c *cli.Context) error {
ResourcesList()
modulesArray := ResourcesList()
modulesString := strings.Join(modulesArray,"\n")
fmt.Println(modulesString)
return nil
},
},
Expand Down

0 comments on commit 9e29dc6

Please sign in to comment.