Commit Graph

105 Commits

Author SHA1 Message Date
Annie Cherkaev
f1514dd301
Add support for BEP 39.
Add update-url field to info struct.

See BEP 39 for more details:
http://bittorrent.org/beps/bep_0039.html

type: added
fixes:
- https://github.com/casey/intermodal/issues/98
2020-04-27 17:47:40 -07:00
Casey Rodarmor
8fbe39726f
Add notes for packagers to readme
type: documentation
2020-04-23 14:59:49 -07:00
Casey Rodarmor
25ac072985
Allow positional input to imdl torrent show
Input can now be passed to `imdl torrent show` without a flag:

  imdl torrent show foo.torrent

Passing input by flag continues to work.

type: changed
fixes:
- https://github.com/casey/intermodal/issues/375
2020-04-22 00:38:00 -07:00
Casey Rodarmor
cecd2f66a5
Fix help strings
Fix inconsistent argument value names in help strings.

type: fixed
2020-04-22 00:29:14 -07:00
Casey Rodarmor
ebec2d591a
Allow positional shell to imdl completions
The shell can now be passed to `imdl completions` without a flag:

  imdl completions bash

Passing the shell by flag continues to work.

type: changed
fixes:
- https://github.com/casey/intermodal/issues/375
2020-04-21 23:57:53 -07:00
Casey Rodarmor
134c241ae7
Use lexiclean crate for lexical path cleaning
I moved all the lexical path cleaning functionality into a separate
crate, so it can be used by other projects.

type: reform
2020-04-21 23:10:34 -07:00
Casey Rodarmor
323434d0aa
Allow positional input to imdl torrent verify
Input can now be passed to `imdl torrent verify` without a flag:

  imdl torrent verify foo.torrent

Passing input by flag continues to work.

type: changed
fixes:
- https://github.com/casey/intermodal/issues/375
2020-04-21 22:35:41 -07:00
Casey Rodarmor
5ba885dbc4
Take input to imdl torrent create as positional
Allow taking the `--input` argument to `imdl torrent create` as a
positional argument, so the following now works:

    imdl torrent create foo

Taking input by flag `--input` still works.

type: changed
fixes:
- https://github.com/casey/intermodal/issues/375
2020-04-21 22:23:39 -07:00
Casey Rodarmor
4f4464e3a2
Get st_flags from MetadataExt on MacOS
I missed that `st_flags` is available on `MetadataExt` on MacOS, so get
them from there, instead of calling `libc::stat`.

type: reform
2020-04-21 00:03:16 -07:00
Celeo
deca555ac3
Allow suppressing output with --quiet
Add a global flag `--quiet`, which allows supressing output from
`imdl torrent create` and `imdl torrent verify`.

Since it's a global option, it should be given before the subcommand,
e.g.:

    imdl --quiet torrent create --input .

type: added
fixes:
- https://github.com/casey/intermodal/issues/174
2020-04-20 21:37:07 -07:00
Celeo
9b72873ed1
Optionally respect .gitignore in imdl torrent create
Add a '--ignore' flag that, when passed, causes `imdl torretn create` to
skip files listed in `.gitignore`, `.ignore`, `.git/info/exclude`, and
`git config --get core.excludesFile`.

Also switches from the `walkdir` crate to the `ignore` crate, which uses
`walkdir` internally, and which handles `.gitignore` and `.ignore`
files.

This changes the behavior of `-include-hidden` on MacOS to no longer
skip entries with the hidden attribute set, due to `ignore` not exposing
`walkdir`'s filter functionality.

A PR[0] is pending to add filtering to `ignore`, so hopefully this
functionality can be re-implemented soon.

[0] https://github.com/BurntSushi/ripgrep/pull/1557

type: added
fixes:
- https://github.com/casey/intermodal/issues/378
2020-04-20 19:20:12 -07:00
Casey Rodarmor
65597c9851
Add --terminal override terminal autodetection
The `--terminal` flag can be used to override terminal autodetection and
force `imdl` to behave as if standard error and standard output are
connected to a terminal.

type: added
fixes:
- https://github.com/casey/intermodal/issues/398
2020-04-19 22:51:18 -07:00
Casey Rodarmor
87687f4dec
Add custom 404 page to site
type: documentation
2020-04-18 23:43:24 -07:00
Casey Rodarmor
09b0ee316c
Document piece length selection algorithm
Add a page to the book discussing factors in piece length selection, and
Intermodal's piece length selection algorithm.

type: documentation
pr: https://github.com/casey/intermodal/pull/392
fixes:
- https://github.com/casey/intermodal/issues/367
2020-04-18 23:12:31 -07:00
Casey Rodarmor
a6bf752791
Use invariant instead of unwrap and expect
Add the `Invariant` trait, which provides `Invariant::invariant` and
`Invariant::invariant_unwrap` methods, and use them instead of unwrap
and expect.

I think these methods are a bit clearer than `unwrap` and `expect`,
since they more clearly document intent, i.e. that the thing passed to
`invariant` should be a description of an invariant that should always
be true, and should provide better error messages.

Replace uses of `unwrap` and `expect` with `invariant`.

type: reform
fixes:
- https://github.com/casey/intermodal/issues/167
2020-04-18 14:41:27 -07:00
Casey Rodarmor
faf46c0f0e
Test that globs match torrent contents
Globs should match paths within the torrent root, not including the
torrent root. Test that this is the case.

type: testing
fixes:
- https://github.com/casey/intermodal/issues/377
2020-04-18 13:46:50 -07:00
Casey Rodarmor
0a870ed2ee
Get current time early when creating torrents
Since getting the system time is fallible, do it early when creating a
torrent, so as to avoid potentially wasting time searching and hashing.

type: reform
fixes:
- https://github.com/casey/intermodal/issues/207
2020-04-18 13:24:44 -07:00
Casey Rodarmor
04338e3501
Merge documentation and changelog generation
Merge documentation generation into a single binary, `bin/gen`. This
includes: The changelog, man pages, the readme, and the book.

type: reform
2020-04-17 21:31:54 -07:00
strickinato
cb8b5a6919
Partially implement BEP 53
This enables `--select-only 1,2,3` which gets appended to the magnet
link as `&so=1,2,3`.

It's a partial implementation because we're missing support for file
ranges ie `--select-only 4-6`

type: added
fixes:
- https://github.com/casey/intermodal/issues/245
2020-04-12 20:42:45 -07:00
Casey Rodarmor
727d5c1028
Fix Z Shell completions
The clap-generated zsh completion scripts use unescaped double-quoted
strings for the subocommand description text, which causes backtick
characters to be evaluated.

Remove backticks from the subcommand descriptions, to un-break the zsh
completion scripts.

type: fixed
pr: https://github.com/casey/intermodal/pull/365
2020-04-11 04:22:22 -07:00
Casey Rodarmor
f05807290b
Render command help text in book to avoid wrapping
The command `--help` text output in the book was very wide, which caused
it to be clipped and require scrolling horizontally to see it all.

This diff renders the text at 80 columns, which makes it visible without
scrolling at reasonable screen sizes.

To do this, `env::run` now checks for the presence of the environment
variable `IMDL_TERM_WIDTH`, which, if set to a positive integer, will be
passed to `Clap::set_term_width`.

`bin/man` now uses this to render the help text at 80 characters.

type: documentation
pr: https://github.com/casey/intermodal/pull/364
2020-04-11 04:00:52 -07:00
Casey Rodarmor
ff6f6d4c3d
Test that --globs match entire file paths
E.g. `--glob x*` matches `x/y`.

type: testing
pr: https://github.com/casey/intermodal/pull/357
2020-04-10 17:11:00 -07:00
Casey Rodarmor
4dfe537fa5
Prevent progress bar from overflowing
Use the `wide_bar` indicatif format specifier to truncate the progress
bar when the terminal is narrow. This prevents the progress bar from
printing mulitple times when the terminal is narrow

type: fixed
pr: https://github.com/casey/intermodal/pull/353
2020-04-10 15:04:28 -07:00
Casey Rodarmor
e54bdeb95d
Remove use of unreachable in favor of internal errors
type: reform
pr: https://github.com/casey/intermodal/pull/351
fixes:
- https://github.com/casey/intermodal/issues/188
2020-04-09 20:07:43 -07:00
Casey Rodarmor
a395052f7c
Deduplicate progress style string
type: reform
2020-04-07 22:10:49 -07:00
Casey Rodarmor
6edab1fa3f
Use TestEnv::assert_ok everywhere
`TestEnv::assert_ok` prints stderr and stdout, and so provides more
information in the event of an error.

type: reform
fixes:
- https://github.com/casey/intermodal/issues/330
2020-04-07 19:38:06 -07:00
Casey Rodarmor
8e3f5516af
Use attractive paths in user-facing messages
If a user passes `--input foo`, print "Searching `foo` for files…",
instead of the resolved, absolute path to `foo`, since the former is
what the user typed in.

This was way harder, and had way more edge cases, than I thought it would
be!

One takaway, lexical path cleaning is excellent.

type: changed
fixes:
- https://github.com/casey/intermodal/issues/252
- https://github.com/casey/intermodal/issues/332
2020-04-07 19:37:51 -07:00
Casey Rodarmor
1cfc021453
Forbid empty input, output, and path targets
When an empty path is passed to `Env::resolve`, the result is the
current working directory. This is bad, so forbid the user to pass in
empty paths.

type: fixed
2020-04-07 19:01:43 -07:00
Eric Siegel
c23b0635ee
Add ability to create single-file torrents from stdin
Torrents may now be created from standard input by passing `--input -`.

Since `--name` and `--output` cannot be deduced, they are required when
`--input -`.

type: added
2020-04-07 19:01:43 -07:00
Casey Rodarmor
8c30205b02
Add shell completion scripts
Shell completion scripts can be generated for `bash`, `elvish`, `fish`,
`powershell`, and `zsh` with the `completions` subcommand:

    $ imdl completions --shell zsh > imdl.zsh

The same scripts are available in the `completions` directory. Please
refer to your shell's documentation for more information on how to
install and use completion scripts.

type: added
2020-04-07 19:01:37 -07:00
Casey Rodarmor
97018031c1
Introduce "sort specs" to allow fine-grained sorting of files in torrents
Sort specs are of the form `KEY:ORDER`, and allow sorting files in a
torrent by multiple criteria. Multiple sort specs can be passed with
`--sort-by` upon torrent creation.

type: added
2020-04-07 19:01:33 -07:00
Casey Rodarmor
362a81d42f
Use strum crate to derive enum↔string conversions
type: reform
2020-04-07 19:01:33 -07:00
Eric
1cd6c276fd
Allow sorting files in torrents
The order in which files appear in torrents can now be controlled
with the `--order` flag:

    imdl torrent create --input foo --order alphabetical-asc

See `--help` documentation for possible values.

type: added
2020-04-07 19:01:32 -07:00
Casey Rodarmor
6328118c00
Use open crate to open files and URLs
Opening URLs on Windows is very complex, so delegate to the
`open` crate.

type: changed
2020-04-07 19:01:31 -07:00
Casey Rodarmor
972a1ec628
Merge Github Actions workflows
type: development
2020-04-07 19:01:30 -07:00
Casey Rodarmor
86aeec3ce9
Fix release process issues
- Trigger GitHub Actions workflow on release tags
- Make build script tolerate not being called in git directory
- Omit git hash in created by message if not built in git directory
- Test created by message format

type: distribution
2020-04-07 19:01:29 -07:00
Casey Rodarmor
498549b35c
Allow reading torrent metainfo from stdin
Torrent metainfo can be read from standard input by passing `-`:

    cat a.torrent | imdl torrent verify --input -
    cat a.torrent | imdl torrent link --input -
    cat a.torrent | imdl torrent show --input -

type: added
2020-04-07 19:01:29 -07:00
Casey Rodarmor
1c84172ad4
Skip torrent file creation with imdl torrent create --dry-run
Torrent files will not be written to disk with `--dry-run`:

    imdl torrrent create --input foo --dry-run

type: added
2020-04-07 19:01:28 -07:00
Casey Rodarmor
0d7c1c0c27
Print magnet link to stdout with --link
Magnet links can be printed to standard output with:

    imdl torrent create --input PATH --link

type: added
2020-04-07 19:01:28 -07:00
Casey Rodarmor
d8055c6e6a
Allow opening magnet links after creation
Magnet links can now be opened after creation:

    imdl torrent link --open --input METAINFO

type: added
2020-04-07 19:01:28 -07:00
Casey Rodarmor
aeb9d8b317
Add name and peers to magnet links
Add additional data to magnet links in `imdl torrent link`.

- Set the `dn` query parameter with `metinfo.info.name`
- Add peers to the `x.pe` query parameter:

    imdl torrent link --peer HOST:PORT

type: added
2020-04-07 19:01:28 -07:00
Casey Rodarmor
57a358e458
Allow creating magnet links with imdl torrent link
Magnet links can now be created from a metainfo file with:

    imdl torrent link --input METAINFO

type: added
2020-04-07 19:01:27 -07:00
Casey Rodarmor
3257614c4f
Print correct and incorrect MD5 checksums in color
type: changed
2020-04-07 19:01:27 -07:00
Casey Rodarmor
1cac9ab924
Use imdl-indicatif
The `0.1.0` release is coming up, and a prerequisite to publish to
crates.io is to not depend on any non crates.io dependency.

We're using the `{binary_bytes_per_sec}` formatting spec, which is only
in my fork.

I published my fork to crates.io as `imdl-indicatif`, and this diff
starts depending on that fork.

type: distribution
2020-04-07 19:01:27 -07:00
Casey Rodarmor
0033e8381f
Test imdl torrent verify output
- Test all individual `FileError` variants
- Test terminal colors
- Test multiple and single file torrents

type: testing
2020-04-07 19:01:27 -07:00
Casey Rodarmor
2ea5e0b384
Deny clippy::too_many_arguments
type: development
2020-04-07 19:01:26 -07:00
Casey Rodarmor
1532113782
Print individual file torrent verification errors
If torrent verification fails, print all errors with individual files.

type: changed
2020-04-07 19:01:26 -07:00
Casey Rodarmor
1daa18ef9a
Add progress messages and bar to imdl torrent verify
type: added
2020-04-07 19:01:26 -07:00
Casey Rodarmor
5a0bd2dda7
Add braille spinner char explanation and legend
type: documentation
2020-04-07 19:01:25 -07:00
Casey Rodarmor
2edf8a4fab
Style imdl torrent create progress messages
type: changed
2020-04-07 19:01:25 -07:00