man

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &command.Command{
	Cobra: &cobra.Command{
		Use:   "man",
		Short: "Generates and installs Joyent Manta cli man pages",
		Long: `This command automatically generates up-to-date man pages of Manta CLI
command-line interface.  By default, it creates the man page files
in the "docs/man" directory under the current directory.`,

		PreRunE: func(cmd *cobra.Command, args []string) error {
			return nil
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			header := &doc.GenManHeader{
				Manual:  "Manta",
				Section: strconv.Itoa(config.ManSect),
				Source:  strings.Join([]string{"Manta", triton.Version}, " "),
			}

			manDir := viper.GetString(config.KeyDocManDir)

			manSectDir := path.Join(manDir, fmt.Sprintf("man%d", config.ManSect))
			if _, err := os.Stat(manSectDir); os.IsNotExist(err) {
				if err := os.MkdirAll(manSectDir, 0777); err != nil {
					return errors.Wrapf(err, "unable to make mandir %q", manSectDir)
				}
			}

			cmd.Root().DisableAutoGenTag = true
			log.Info().Str("MANDIR", manDir).Int("section", config.ManSect).Msg("Installing man(1) pages")

			err := doc.GenManTree(cmd.Root(), header, manSectDir)
			if err != nil {
				return errors.Wrap(err, "unable to generate man(1) pages")
			}

			log.Info().Msg("Installation completed successfully.")

			return nil
		},
	},
	Setup: func(parent *command.Command) error {

		{
			const (
				key          = config.KeyDocManDir
				longName     = "man-dir"
				shortName    = "m"
				description  = "Specify the MANDIR to use"
				defaultValue = config.DefaultManDir
			)

			flags := parent.Cobra.PersistentFlags()
			flags.StringP(longName, shortName, defaultValue, description)
			viper.BindPFlag(key, flags.Lookup(longName))
			viper.BindEnv(key, "MANDIR")
			viper.SetDefault(key, defaultValue)
		}

		return nil
	},
}

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