devtools

package
v0.53.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmd

func Cmd(initializers ...workflow.ExtensionInit) (*cobra.Command, error)

Cmd is a helper utility for extension authors to define a lightweight CLI to test their extensions outside of the main Snyk CLI.

Example
package main

import (
	"fmt"
	"log"

	"github.com/snyk/go-application-framework/pkg/devtools"
	"github.com/snyk/go-application-framework/pkg/workflow"
	"github.com/spf13/pflag"
)

var helloWorkflowID = workflow.NewWorkflowIdentifier("hello")

func helloWorkflow(
	ictx workflow.InvocationContext,
	_ []workflow.Data,
) ([]workflow.Data, error) {
	fmt.Println("Hello, workflow!")

	return []workflow.Data{}, nil
}

func initHelloWorkflow(e workflow.Engine) error {
	flagset := pflag.NewFlagSet("snyk-cli-extension-hello", pflag.ExitOnError)
	c := workflow.ConfigurationOptionsFromFlagset(flagset)
	if _, err := e.Register(helloWorkflowID, c, helloWorkflow); err != nil {
		return fmt.Errorf("error while registering 'hello' workflow: %w", err)
	}
	return nil
}

func main() {
	// Initialize the command with one or more workflows
	root, err := devtools.Cmd(initHelloWorkflow)
	if err != nil {
		log.Fatal(err)
	}

	// This is just for testing. In normal usage, args are set automatically
	// from os.Args.
	root.SetArgs([]string{"hello"})

	// Execute the command.
	if err := root.Execute(); err != nil {
		log.Fatal(err)
	}
}
Output:
Hello, workflow!

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL