genericsCmd

package
v1.2.14 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BulkRenameCmd = &cobra.Command{
	Use:     "rename <pattern> <replacement>",
	Aliases: []string{},
	Short:   "Bulk rename files or directories using regex patterns",
	Long: `Rename multiple files or directories in a single operation using regex patterns.
Examples:
  anbu rename 'old_(.*)' 'new_\1'                 # Rename files matching regex pattern
  anbu rename -d 'old_(.*)' 'new_\1'              # Rename directories instead of files
  anbu rename '(.*)\.(.*)' '\1_backup.\2'         # Add _backup before extension`,
	Args: cobra.ExactArgs(2),
	Run: func(cmd *cobra.Command, args []string) {
		anbuGenerics.BulkRename(args[0], args[1], bulkRenameFlags.renameDirectories, bulkRenameFlags.dryRun)
	},
}
View Source
var ConvertCmd = &cobra.Command{
	Use:     "convert [converter] [data or file]",
	Aliases: []string{"c"},
	Short:   "Convert data between different formats and encodings",
	Long: `Convert data between different formats and encodings.

Examples:
  anbu convert yaml-json config.yaml          # Convert YAML file to JSON
  anbu convert json-yaml data.json            # Convert JSON file to YAML
  anbu convert b64 "Hello World"              # Convert text to base64
  anbu convert b64d "SGVsbG8gV29ybGQ="        # Decode base64 to text
  anbu convert hex "Hello World"              # Convert text to hex
  anbu convert hexd "48656c6c6f20576f726c64"  # Decode hex to text
  anbu convert url "Hello World"              # URL encode text
  anbu convert urld "Hello%20World"           # URL decode text
  anbu convert jwtd "$TOKEN"                  # Decode JWT token`,
	Args: cobra.ExactArgs(2),
	Run: func(cmd *cobra.Command, args []string) {
		converterType := args[0]
		input := args[1]
		anbuGenerics.ConvertData(converterType, input)
	},
}
View Source
var DuplicatesCmd = &cobra.Command{
	Use:     "duplicates",
	Aliases: []string{"dup"},
	Short:   "Find duplicate files by content with optional recursive search",
	Args:    cobra.NoArgs,
	Run: func(cmd *cobra.Command, args []string) {
		anbuGenerics.FindDuplicates(duplicatesFlags.recursive)
	},
}
View Source
var ManualRenameCmd = &cobra.Command{
	Use:     "manual-rename",
	Aliases: []string{"mrename"},
	Short:   "Interactively rename files and directories one by one, optionally including directories, hidden files, and extensions",
	Args:    cobra.NoArgs,
	Run: func(cmd *cobra.Command, args []string) {
		anbuGenerics.ManualRename(manualRenameFlags.includeDir, manualRenameFlags.hidden, manualRenameFlags.includeExtension)
	},
}
View Source
var MarkdownCmd = &cobra.Command{
	Use:     "markdown",
	Aliases: []string{"md"},
	Short:   "Start a markdown viewer web server",
	Run: func(cmd *cobra.Command, args []string) {
		err := anbuGenerics.StartMarkdownServer(markdownFlags.listenAddress)
		if err != nil {
			log.Fatal().Err(err).Msg("Failed to start markdown viewer")
		}
	},
}
View Source
var SedCmd = &cobra.Command{
	Use:     "sed <pattern> <replacement> <path>",
	Aliases: []string{},
	Short:   "Apply regex substitution to file content",
	Long: `Replace text patterns in single files or entire directories using regex patterns.

Examples:
  anbu sed 'old_(.*)' 'new_\1' path/to/file.txt  # Replace text in file
  anbu sed 'old_(.*)' 'new_\1' path/to/dir       # Replace text in all files in directory
  anbu sed 'old_(.*)' 'new_\1' path/to/dir -r    # Perform a dry-run without applying changes`,
	Args: cobra.ExactArgs(3),
	Run: func(cmd *cobra.Command, args []string) {
		anbuGenerics.Sed(args[0], args[1], args[2], sedFlags.dryRun)
	},
}
View Source
var StashCmd = &cobra.Command{
	Use:   "stash",
	Short: "Manage a persistent clipboard for files, folders, and text",
}
View Source
var StringCmd = &cobra.Command{
	Use:     "string",
	Aliases: []string{"s"},
	Short:   "Generate random strings, sequences, passwords, and passphrases",
	Long: `Generate random strings, sequences, passwords, and passphrases.
Examples:
  anbu string 23                       # generate 23 (100 if not specified) random alphanumeric chars
  anbu string seq 29                   # prints "abcdefghijklmnopqrstuvxyz" until desired length
  anbu string rep 23 str2rep           # prints "str2repstr2rep...23 times"
  anbu string uuid                     # generates a uuid
  anbu string ruid 16                  # generates a short uuid of length b/w 1-32
  anbu string suid                     # generates a short uuid of length 18
  anbu string password                 # generate a 12-character complex password
  anbu string password 16              # generate a 16-character complex password
  anbu string password 8 simple        # generate an 8-letter lowercase password
  anbu string passphrase               # generate a 3-word passphrase with hyphens
  anbu string passphrase 5             # generate a 5-word passphrase with hyphens
  anbu string passphrase 4 '@'         # generate a 4-word passphrase with a custom separator`,
	Args: cobra.ArbitraryArgs,
	Run: func(cmd *cobra.Command, args []string) {

		if len(args) == 0 {
			anbuGenerics.GenerateRandomString(0)
			return
		}

		if len, err := strconv.Atoi(args[0]); err == nil {
			anbuGenerics.GenerateRandomString(len)
			return
		}

		if args[0] == "seq" {
			if len(args) < 2 {
				log.Fatal().Msg("Missing length for sequence command")
			}
			length, err := strconv.Atoi(args[1])
			if err != nil {
				log.Fatal().Msg("Not a valid length")
			}
			anbuGenerics.GenerateSequenceString(length)
			return
		}

		if args[0] == "rep" {
			if len(args) < 3 {
				log.Fatal().Msg("Missing count or string for repetition")
			}
			count, err := strconv.Atoi(args[1])
			if err != nil {
				log.Fatal().Msg("Not a valid count")
			}
			anbuGenerics.GenerateRepetitionString(count, args[2])
			return
		}
		if args[0] == "uuid" {
			anbuGenerics.GenerateUUIDString()
			return
		}
		if args[0] == "ruid" {
			if len(args) < 2 {
				log.Fatal().Msg("Missing length for RUID command")
			}
			anbuGenerics.GenerateRUIDString(args[1])
			return
		}
		if args[0] == "suid" {
			anbuGenerics.GenerateRUIDString("18")
			return
		}
		if args[0] == "password" {
			if len(args) < 2 {
				anbuGenerics.GeneratePassword("12", false)
			} else if len(args) == 2 {
				anbuGenerics.GeneratePassword(args[1], false)
			} else if len(args) == 3 {
				anbuGenerics.GeneratePassword(args[1], true)
			}
			return
		}
		if args[0] == "passphrase" {
			if len(args) < 2 {
				anbuGenerics.GeneratePassPhrase("3", "-", false)
			} else if len(args) == 2 {
				anbuGenerics.GeneratePassPhrase(args[1], "-", false)
			} else if len(args) == 3 {
				if args[2] == "simple" {
					anbuGenerics.GeneratePassPhrase(args[1], "-", true)
				} else {
					anbuGenerics.GeneratePassPhrase(args[1], args[2], false)
				}
			}
			return
		}

		cmd.Help()
	},
}
View Source
var TimeCmd = &cobra.Command{
	Use:     "time",
	Aliases: []string{"t"},
	Short:   "Display and analyze time in various formats and perform epoch diffs, time parsing, and time remaining calculations",
	Args:    cobra.MaximumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			anbuGenerics.TimeCurrent()
			return
		}
		switch args[0] {
		case "now":
			anbuGenerics.TimeCurrent()
		case "purple":
			anbuGenerics.TimePurple()
		case "iso":
			anbuGenerics.TimeISO()
		case "diff":
			anbuGenerics.TimeEpochDiff(timeCmdFlags.epochs)
		case "parse":
			anbuGenerics.TimeParse(timeCmdFlags.timeStr, timeCmdFlags.parseAction)
		case "until":
			anbuGenerics.TimeParse(timeCmdFlags.timeStr, "diff")
		default:
			anbuGenerics.TimeCurrent()
		}
	},
}

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