cli

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BindlGenerate = &cobra.Command{
	Use:     "generate",
	Aliases: []string{"gen"},
	Short:   "Generate project integration files (e.g. Makefile, .gitignore)",
	Long:    `Generate common setup for projects to have smooth workflow.`,
}
View Source
var BindlGenerateIgnore = &cobra.Command{
	Use:   "ignore",
	Short: "Generate ignore file for bindl programs",
	Long: `Generate ignore file for bindl programs 

By default, Bindl will take ".gitignore" as input and append 
<output directory>/* if it doesn't already exist.

For example, with default output directory "bin":

  $ bindl ignore -f .gitignore
  $ tail -n 1 .gitignore
  bin/*

Supports typical ignore files. e.g. .dockerignore`,
	RunE: func(cmd *cobra.Command, args []string) error {
		return command.UpdateIgnoreFile(conf, bindlGenerateIgnorePath)
	},
}
View Source
var BindlGenerateMake = &cobra.Command{
	Use:     "make",
	Aliases: []string{"makefile"},
	Short:   "Generate Makefile for bindl programs",
	Long: `Generate Makefile for all programs in lockfile.

By default, the generated Makefile will be named 'Makefile.bindl', which can be
imported by the project's primary Makefile using 'include' directive.

After including, you can use rules defined in 'Makefile.bindl' as a dependency
in your other rules. For example:

	$ head -n 5 Makefile
	include Makefile.bindl

	.PHONY: container
	container: bin/ko
		bin/ko publish -B .

Calling the imported rules also works on 'make' CLI.`,
	RunE: func(cmd *cobra.Command, args []string) error {
		return command.GenerateMakefile(conf, bindlGenerateMakefilePath)
	},
}
View Source
var BindlGet = &cobra.Command{
	Use:   "get [name, ...]",
	Short: "Get local copy of program",
	Long: `Get downloads the names program, which must already exist in bindl.yaml,
and ensures the program is ready to be used by setting executable flag. If no 
program name is specified through args, then all programs in lockfile will be selected.

While it is unlikely for end-user to need it, the flag --bootstrap is provided to download
internally trusted program. Bootstrap mode uses pre-defined values of program validations
at compile time. In bootstrap mode, program name must be specified in args.`,
	RunE: func(cmd *cobra.Command, names []string) error {
		if bindlGetBootstrap {
			return getBootstrap(cmd.Context(), names)
		}
		err := command.IterateLockfilePrograms(
			cmd.Context(),
			conf,
			names,
			command.Get)
		return err
	},
}
View Source
var BindlList = &cobra.Command{
	Use:   "list",
	Short: "List out programs defined in lockfile",
	Long:  "List shows all program names defined in lockfile.",

	Args: cobra.NoArgs,

	RunE: func(cmd *cobra.Command, args []string) error {
		l, err := config.ParseLock(conf.LockfilePath)
		if err != nil {
			return fmt.Errorf("parsing lockfile: %w", err)
		}
		separator := "\n"
		if bindlListOneline {
			separator = " "
		}
		for _, p := range l.Programs {
			fmt.Printf("%s%s", p.Name, separator)
		}
		if bindlListOneline {
			fmt.Println()
		}
		return nil
	},
}
View Source
var BindlPurge = &cobra.Command{
	Use:   "purge",
	Short: "Remove downloaded programs",
	Long: `Remove downloaded programs from cache, which are not listed in the lockfile.
Passing --all would remove all existing programs regardless of lockfile.`,
	RunE: func(cmd *cobra.Command, names []string) error {
		return command.Purge(cmd.Context(), conf, bindlPurgeAll, bindlPurgeDryRun)
	},
}
View Source
var BindlSync = &cobra.Command{
	Use:   "sync",
	Short: "Sync configuration and lockfile",
	Long: `Synchronize bindl configuration with lockfile.

Sync will update lockfile (i.e. .bindl-lock.yaml) according to configuration
file specifications (i.e. bindl.yaml), ensuring that checksums exists in
lockfile for all desired platforms and programs.`,
	Args: cobra.NoArgs,
	RunE: func(cmd *cobra.Command, args []string) error {
		return command.Sync(cmd.Context(), conf, bindlSyncStdout)
	},
}
View Source
var BindlVerify = &cobra.Command{
	Use:     "verify [name, ...]",
	Aliases: []string{"validate"},
	Short:   "Verify current installation of a program",
	Long: `Verify if the currently installed program matches the specified checksum in lockfile.
If no program name is specified through args, then all programs in lockfile
will be selected.`,
	RunE: func(cmd *cobra.Command, names []string) error {
		return command.IterateLockfilePrograms(
			cmd.Context(),
			conf,
			names,
			command.Verify)
	},
}
View Source
var Root = &cobra.Command{
	Use:  "bindl",
	Long: "Bindl is a static binary downloader for project development and infrastructure.",
	PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
		if err := envconfig.Process("BINDL", conf); err != nil {
			return err
		}

		var logLevel string
		switch {
		case conf.Silent:
			logLevel = "disabled"
		case conf.Debug:
			logLevel = "debug"
		default:
			logLevel = "info"
		}
		return log.SetLevel(logLevel)
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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