-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mathieu Frenette <[email protected]>
- Loading branch information
Showing
10 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package actions | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Samasource/jen/src/cmd/internal" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// New creates a cobra command | ||
func New(options *internal.Options) *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "actions", | ||
Aliases: []string{"action"}, | ||
Short: "Lists actions available in current template", | ||
Args: cobra.NoArgs, | ||
RunE: func(_ *cobra.Command, args []string) error { | ||
return run(options, args) | ||
}, | ||
} | ||
} | ||
|
||
func run(options *internal.Options, args []string) error { | ||
execContext, err := options.NewContext() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, action := range execContext.GetActionNames() { | ||
fmt.Println(action) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package list | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/Samasource/jen/src/cmd/internal" | ||
"github.com/Samasource/jen/src/cmd/list/actions" | ||
"github.com/Samasource/jen/src/internal/shell" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// New creates a cobra command | ||
func New(options *internal.Options) *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: "list", | ||
Aliases: []string{"ls"}, | ||
Short: "Lists available templates, actions, variables or scripts", | ||
RunE: func(_ *cobra.Command, args []string) error { | ||
return run(options, args) | ||
}, | ||
} | ||
c.AddCommand(actions.New(options)) | ||
return c | ||
} | ||
|
||
func run(options *internal.Options, args []string) error { | ||
execContext, err := options.NewContext() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return shell.Execute(execContext.GetShellVars(), "", strings.Join(args, " ")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters