Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #6

Merged
merged 5 commits into from
Nov 25, 2019
Merged

V2 #6

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions Makefile

This file was deleted.

138 changes: 0 additions & 138 deletions README.md

This file was deleted.

46 changes: 46 additions & 0 deletions cmd/packman/controllers/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package controllers

import (
"fmt"
"github.com/securenative/packman/internal"
"github.com/urfave/cli"
"strings"
)

var AuthController = cli.Command{
Name: "auth",
Aliases: []string{"a"},
Usage: "packman auth <username> <password>",
UsageText: "saving the auth information to your git repositories",
Action: func(c *cli.Context) error {
return auth(c)
},
}

var ScriptEngineController = cli.Command{
Name: "script",
Aliases: []string{"s"},
Usage: "packman script <script_command>",
UsageText: "changes the command which meant to run the packman template script",
Action: func(c *cli.Context) error {
return changeScriptEngine(c)
},
}

func auth(c *cli.Context) error {
if c.NArg() != 2 {
return fmt.Errorf("auth expects exactly 2 arguments but got %d arguments", c.NArg())
}
username := c.Args().Get(0)
password := c.Args().Get(1)
return internal.M.ConfigService.SetAuth(username, password)
}

func changeScriptEngine(c *cli.Context) error {
if c.NArg() != 1 {
return fmt.Errorf("script expects exactly 1 arguments but got %d arguments", c.NArg())
}
script := c.Args().Get(0)
script = strings.ReplaceAll(script, `"`, "")
return internal.M.ConfigService.SetDefaultEngine(script)
}
43 changes: 0 additions & 43 deletions cmd/packman/controllers/configure.go

This file was deleted.

28 changes: 0 additions & 28 deletions cmd/packman/controllers/init.go

This file was deleted.

38 changes: 16 additions & 22 deletions cmd/packman/controllers/pack.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
package controllers

import (
"errors"
"fmt"
"gopkg.in/urfave/cli.v2"
"github.com/securenative/packman/internal"
"github.com/urfave/cli"
)

var PackCommand = cli.Command{
var PackController = cli.Command{
Name: "pack",
Aliases: []string{"p"},
Usage: "pack <package-name> <path>",
UsageText: "Will pack the given folder and push it to the backend so it can be later located using the package-name",
Action: func(context *cli.Context) error {

if context.NArg() != 2 {
fmt.Println("pack expects exactly 2 arguments")
}

packageName := context.Args().Get(0)
path := context.Args().Get(1)

if packageName == "" {
return errors.New("you must provide a package name")
}
Usage: "packman pack <path> <remote_url>",
UsageText: "packing a folder by pushing it to the configured git's remote",
Action: func(c *cli.Context) error {
return pack(c)
},
}

if path == "" {
return errors.New("you must provide a path to the project")
}
func pack(c *cli.Context) error {
if c.NArg() != 2 {
return fmt.Errorf("pack expects exactly 2 arguments but got %d arguments", c.NArg())
}

return PackmanModule.Packer.Pack(packageName, path)
},
path := c.Args().Get(0)
remote := c.Args().Get(1)
return internal.M.TemplatingService.Pack(remote, path)
}
29 changes: 29 additions & 0 deletions cmd/packman/controllers/render.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package controllers

import (
"fmt"
"github.com/securenative/packman/internal"
"github.com/securenative/packman/internal/etc"
"github.com/urfave/cli"
)

var RenderController = cli.Command{
Name: "render",
Aliases: []string{"r"},
Usage: "packman render <path> [-flagName flagValue]...",
UsageText: "unpacking a template project with the given flags",
Action: func(c *cli.Context) error {
return render(c)
},
}

func render(c *cli.Context) error {
if c.NArg() < 1 {
return fmt.Errorf("unpack expects exactly 1 argument but got %d arguments", c.NArg())
}

path := c.Args().Get(0)
flagsMap := etc.ArgsToFlagsMap(c.Args()[1:])

return internal.M.TemplatingService.Render(path, fmt.Sprintf("%s-rendered", path), flagsMap)
}
7 changes: 0 additions & 7 deletions cmd/packman/controllers/singleton.go

This file was deleted.

Loading