ln

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cli.Command{
	Name:  "ln",
	Usage: "Make links between files",
	Flags: []cli.Flag{
		&cli.BoolFlag{Name: "symbolic, s", Usage: "Create symbolic link instead of hard link"},
	},
	Action: func(ctx context.Context, cmd *cli.Command) error {
		symbolic := cmd.Bool("symbolic")

		files := cmd.Args().Slice()
		if len(files) < 2 {
			return fmt.Errorf("missing file operand")
		}

		target := files[0]
		linkName := files[1]

		target, _ = filepath.Abs(target)

		if runtime.GOOS == "windows" {
			if symbolic {
				return createSymlink(target, linkName)
			}
			return createHardlink(target, linkName)
		}

		if symbolic {
			return os.Symlink(target, linkName)
		}
		return os.Link(target, linkName)
	},
}

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