migration

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 15 Imported by: 0

README

goopt Migration Tools

This package provides tools to help migrate from the legacy goopt tag format to the new format. It will be removed in a future version once the migration period is over.

Usage

CLI Tool

Install the migration tool:

go install github.com/napalu/goopt/cmd/goopt-migrate@latest

Convert a single file:

goopt-migrate -f path/to/file.go

Convert a directory:

goopt-migrate -d path/to/dir

Options:

  • -f, --file: Process a single file
  • -d, --dir: Process a directory (recursively)
  • -r, --dry-run: Show what would be changed without making changes
  • -v, --verbose: Show detailed progress
API Usage
package main
import "github.com/napalu/goopt/migration"

// Convert a single file
err := migration.ConvertFile("path/to/file.go")

// Convert a directory
err := migration.ConvertDir("path/to/dir")

Migration Period

This package will be removed in v2.0.0. Please ensure all your code is migrated before upgrading.

Manual Migration

If you prefer to migrate manually, replace legacy tags like:

`long:"output" short:"o" description:"Output file"`

With the new format:

`goopt:"name:output;short:o;desc:Output file"`

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertDir

func ConvertDir(dir string, baseDir string) error

ConvertDir converts all .go files in a directory (non-recursive) to the new struct tag format

func ConvertSingleFile

func ConvertSingleFile(filename string, baseDir string) error

ConvertSingleFile converts a single file .go file to the new struct tag format

func PreviewChanges

func PreviewChanges(filename string) (string, error)

PreviewChanges shows what would be changed without making modifications

Types

This section is empty.

Jump to

Keyboard shortcuts

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