Giter VIP home page Giter VIP logo

migrate's Introduction

Migrate

Dead simple file migration tool.

How it works

Migrate doesn't actually move data by itself. It's simply a wrapper over whatever copying utility you want to use. It reads a file manifest calls the copying utility to actually move the files. This approach means that you can use whatever copying utility you normally use (see below).

As long as the utility accepts their input in the correct format (utility -flags source dest), it will work with Migrate.

Why?

I'm lazy and I wanted like to move files from all over my drives to their own destinations in a single command. At the same time, I wanted to be able to preview and modify the paths before executing the command.

How to use

Migrate can operate on files (and directories) or manifest files. The tool can also generate the manifest file.

Generate manifest

migrate generate [flags] <source> <destination> [manifest]

By default, the manifest will be saved as manifest.txt in the current directory. If source is a directory, the tool will scan its contents and instead add its children as entries to the manifest. This is NOT done recursively, so it's up to the copying utility to handle directories.

The generate subcommand supports the following flags:

Flag Type Default Descriptions
overwrite bool false Overwrite the manifest instead of appending to it.
rel-src bool true Use paths relative to the manifest's path when listing the sources.
rel-dest bool false Use paths relative tot he manifest's path when listing the destinations.

Copy files

You can provide a source path and a destination path,

migrate run [flags] <source> <destination>

or provide a path to a manifest.

migrate run [flags] <manifest>

When a manifest is provided, Migrate will read the manifest and copy files to their individual destination as listed in the manifest.

The run subcommand supports the following flags:

Flag Type Default Descriptions
dryrun bool false Run in dry run mode. Simply print the execution commands without executing them.
util string rsync on Linux and macOS, and robocopy on Windows Path to copying utility or its name. Migrate will search for this utility and use it to copy files. On Windows, .exe will be automatically appended.
util-args string -avr on Linux and macOS, and /E /COPY:DAT on Windows Arguments for the copying utility.

Building

Migrate requires Go 1.18 as it makes use of generics. There are no other dependency requirements.

Windows

go build -o out/migrate.exe main.go

Linux

go build -o out/migrate main.go

macOS

You can build for your current architecture,

go build -o out/migrate main.go

or build a universal binary file.

GOOS=darwin GOARCH=amd64 go build -o out/migrate.amd64 main.go
GOOS=darwin GOARCH=arm64 go build -o out/migrate.arm64 main.go
lipo -create -output out/migrate out/migrate.amd64 out/migrate.arm64

migrate's People

Contributors

ghifari160 avatar

Watchers

 avatar

migrate's Issues

fix cleanup script missing *.syso in root dir

Cleanup script will not remove *.syso file from the root directory. It's a pattern issue. The easiest fix is to remove *.syso as well as */***/*.syso instead of just the latter.

Prerelease script cannot find go-winres

Some Actions workflows cannot find go-winres even after the installation step in the prerelease script. It might be because the prerelease script sometimes fails to read GOPATH inside of the action runner.

command generate should only scan source directory if path has trailing slash

Command generate detects if the source path is a directory, and scans its contents if it is. This was done so running migrate generate . destination would create map the current directory contents to destination. However, running migrate generate source destination would map the contents of source (rather than source itself) to destination. This might not be preferable. Ideally, running that command maps source itself to destination. To map the contents of source, a trailing slash can be added (i.e. source/). . can be treated as a special exception to preserve the default behavior.

add macOS installer

While it's not too involved to install command line apps by hand on macOS, it would be nice to have a .pkg installer. A Homebrew Formulae would also be nice, though it probably has to be done outside of the official Taps.

Tasks:

  • Refactor Actions workflows
  • Add macOS installer
  • Add Homebrew Formulae

command run should not read the whole manifest into memory at once

Reading the whole manifest is risky. The command assumes that the file at the user-specified path (or default path) is a text file and is small enough to absorb into memory. This can be disastrous if the file is bigger than the memory available to the runtime. At the very least, there should be some checks about the file size and MIME types. Ideally though, reads should be done line-by-line while parsing the mappings in the manifest.

discard internal pkg lookfor

This internal package implements lookfor.Exe and lookfor.NameMatches. The former looks for an executable in the user's PATH and returns the absolute path to the executable when found. The latter matches two strings (assumed to be file names), assuming case-insensitivity when called on Windows. There was never a need for lookfor.Exe (exec.LookPath exists in the standard library). It was implemented in an error. lookfor.NameMatches can still be useful, but there is no need for it at the moment.

add Windows installer

Installing command line apps by hand in Windows is arguably more involved than in Unix-like platforms. An *.msi Windows installer can resolve this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.