mx is a Rust CLI aiming for compatibility with mc.
Current focus: alias/config management.
Implemented:
mx lsmx mbmx rbmx statmx catmx rmmx cpmx mvmx put/mx outmx alias set/mx alias smx alias list/mx alias lsmx alias remove/mx alias rm--jsonoutput for supported commands
In progress:
- S3 listing parity with
mc ls alias importalias export- full
mcbehavioral parity
cargo buildRun locally:
./target/debug/mx --helpmx alias set myminio http://localhost:9000 minio minio123With explicit options:
mx alias set mys3 https://s3.amazonaws.com ACCESSKEY SECRETKEY --api S3v4 --path autoYou can also omit credentials and enter them interactively or pipe them in.
List all:
mx alias listList one:
mx alias list myminiomx alias remove myminiomx mb myminio/mybucketmx rb myminio/mybucketmx stat myminio/mybucket
mx stat myminio/mybucket/path/file.txtmx cat myminio/mybucket/path/file.txtmx rm myminio/mybucket/path/file.txtmx cp ./local.txt myminio/mybucket/
mx cp myminio/mybucket/remote.txt ./downloaded.txt
mx cp myminio/mybucket/a.txt myminio/mybucket/b.txtmx mv myminio/mybucket/a.txt myminio/mybucket/archive/a.txtmx put ./local.txt myminio/mybucket/
mx out ./local.txt myminio/mybucket/out.txtList buckets on an alias:
mx ls myminioList a bucket root:
mx ls myminio/mybucket/List a prefix:
mx ls myminio/mybucket/photos/Use --json globally:
mx --json alias list
mx --json alias list myminio
mx --json alias set myminio http://localhost:9000 minio minio123
mx --json alias remove myminio
mx --json ls myminio/mybucket/
mx --json mb myminio/mybucket
mx --json stat myminio/mybucket/file.txt
mx --json cp ./local.txt myminio/mybucket/Example:
{
"status": "success",
"alias": "myminio",
"URL": "http://localhost:9000",
"accessKey": "minio",
"secretKey": "minio123",
"api": "S3v4",
"path": "auto"
}mx resolves config in this order:
~/.mx/config.json~/.mc/config.json- if neither exists, create
~/.mx/config.json
That means:
- if
~/.mx/config.jsonexists,mxuses it - otherwise, if
~/.mc/config.jsonexists,mxuses that - otherwise,
mxcreates its own config in~/.mx/config.json
Writes go to whichever config file was selected.
mx currently uses mc-compatible config version 10.
Alias entries use familiar fields such as:
urlaccessKeysecretKeysessionTokenapipath
When mx creates a new config, it seeds these default aliases:
locals3gcsplay
# create/update alias
mx alias set demo http://localhost:9000 minio minio123
# inspect aliases
mx alias list
mx alias list demo
# machine-readable output
mx --json alias list demo
mx --json ls demo/mybucket/
# remove alias
mx alias remove demomxis not yet a full replacement formc- current work is limited to alias management
- output is intentionally similar, but not yet byte-for-byte identical
Run tests:
CARGO_HOME=$PWD/.cargo-home CARGO_TARGET_DIR=$PWD/target cargo testLive S3/MinIO tests are opt-in:
MX_LIVE_TESTS=1 cargo test live_s3_workflow -- --nocaptureYou can point live tests at any S3-compatible server:
MX_LIVE_TESTS=1 \
MX_TEST_ALIAS=mytest \
MX_TEST_URL=https://s3.example.com \
MX_TEST_ACCESS_KEY=... \
MX_TEST_SECRET_KEY=... \
MX_TEST_API=S3v4 \
MX_TEST_PATH=auto \
cargo test live_s3_workflow -- --nocapture