Format with unstable rustfmt options
- Format with nightly rustfmt - Enable unstable options in rustfmt.toml - Turn off git text file detection, so newlines are always unix newlines type: reform
This commit is contained in:
parent
d71bdffda1
commit
f2a5f13729
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
* -text
|
11
.github/workflows/main.yaml
vendored
11
.github/workflows/main.yaml
vendored
|
@ -21,7 +21,7 @@ jobs:
|
|||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install
|
||||
- name: Install Stable
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
|
@ -43,8 +43,15 @@ jobs:
|
|||
- name: Lint
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: ./bin/lint
|
||||
- name: Install Nightly
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: nightly
|
||||
target: ${{matrix.target}}
|
||||
profile: minimal
|
||||
components: rustfmt
|
||||
- name: Format
|
||||
run: cargo fmt --all -- --check
|
||||
run: cargo +nightly fmt --all -- --check
|
||||
- name: Readme
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: |
|
||||
|
|
5
justfile
5
justfile
|
@ -33,6 +33,9 @@ test:
|
|||
clippy:
|
||||
cargo clippy --all
|
||||
|
||||
fmt:
|
||||
cargo +nightly fmt --all
|
||||
|
||||
lint:
|
||||
./bin/lint
|
||||
|
||||
|
@ -59,7 +62,7 @@ check-minimal-versions:
|
|||
|
||||
check: test clippy lint check-minimal-versions
|
||||
git diff --no-ext-diff --quiet --exit-code
|
||||
cargo fmt --all -- --check
|
||||
cargo +nightly fmt --all -- --check
|
||||
cargo run --package update-readme toc
|
||||
git diff --no-ext-diff --quiet --exit-code
|
||||
|
||||
|
|
20
rustfmt.toml
20
rustfmt.toml
|
@ -1,2 +1,18 @@
|
|||
tab_spaces = 2
|
||||
max_width = 100
|
||||
comment_width = 80
|
||||
edition = "2018"
|
||||
error_on_line_overflow = true
|
||||
error_on_unformatted = true
|
||||
format_code_in_doc_comments = true
|
||||
format_macro_bodies = true
|
||||
format_strings = true
|
||||
max_width = 100
|
||||
merge_imports = true
|
||||
newline_style = "Unix"
|
||||
normalize_comments = true
|
||||
reorder_impl_items = true
|
||||
required_version = "1.4.12"
|
||||
tab_spaces = 2
|
||||
unstable_features = true
|
||||
use_field_init_shorthand = true
|
||||
use_try_shorthand = true
|
||||
wrap_comments = true
|
||||
|
|
|
@ -51,7 +51,8 @@ pub(crate) enum Error {
|
|||
#[snafu(display("Failed to find opener utility, please install one of {}", tried.join(",")))]
|
||||
OpenerMissing { tried: &'static [&'static str] },
|
||||
#[snafu(display(
|
||||
"Interal error, this may indicate a bug in intermodal: {}\nConsider filing an issue: https://github.com/casey/imdl/issues/new",
|
||||
"Interal error, this may indicate a bug in intermodal: {}\n\
|
||||
Consider filing an issue: https://github.com/casey/imdl/issues/new",
|
||||
message,
|
||||
))]
|
||||
Internal { message: String },
|
||||
|
@ -104,7 +105,8 @@ pub(crate) enum Error {
|
|||
#[snafu(display("Failed to write to standard output: {}", source))]
|
||||
Stdout { source: io::Error },
|
||||
#[snafu(display(
|
||||
"Attempted to create torrent from symlink `{}`. To override, pass the `--follow-symlinks` flag.",
|
||||
"Attempted to create torrent from symlink `{}`. To override, pass the \
|
||||
`--follow-symlinks` flag.",
|
||||
root.display()
|
||||
))]
|
||||
SymlinkRoot { root: PathBuf },
|
||||
|
|
10
src/opt.rs
10
src/opt.rs
|
@ -17,7 +17,10 @@ pub(crate) struct Opt {
|
|||
long = "unstable",
|
||||
short = "u",
|
||||
help = "Enable unstable features.",
|
||||
long_help = "Enable unstable features. To avoid premature stabilization and excessive version churn, unstable features are unavailable unless this flag is set. Unstable features are not bound by semantic versioning stability guarantees, and may be changed or removed at any time."
|
||||
long_help = "Enable unstable features. To avoid premature stabilization and excessive version \
|
||||
churn, unstable features are unavailable unless this flag is set. Unstable \
|
||||
features are not bound by semantic versioning stability guarantees, and may be \
|
||||
changed or removed at any time."
|
||||
)]
|
||||
unstable: bool,
|
||||
#[structopt(
|
||||
|
@ -26,7 +29,10 @@ pub(crate) struct Opt {
|
|||
set = ArgSettings::CaseInsensitive,
|
||||
possible_values = use_color::VALUES,
|
||||
help = "Print colorful output.",
|
||||
long_help = "Print colorful output. When `auto`, the default, colored output is only enabled if imdl detects that it is connected to a terminal, the `NO_COLOR` environment variable is not set, and the `TERM` environment variable is not set with a value of `dumb`.",
|
||||
long_help = "Print colorful output. When `auto`, the default, colored output is only enabled \
|
||||
if imdl detects that it is connected to a terminal, the `NO_COLOR` environment \
|
||||
variable is not set, and the `TERM` environment variable is not set with a \
|
||||
value of `dumb`.",
|
||||
)]
|
||||
pub(crate) use_color: UseColor,
|
||||
#[structopt(subcommand)]
|
||||
|
|
|
@ -12,42 +12,53 @@ pub(crate) struct Create {
|
|||
long = "announce",
|
||||
required(true),
|
||||
help = "Use `ANNOUNCE` as the primary tracker announce URL.",
|
||||
long_help = "Use `ANNOUNCE` as the primary tracker announce URL. To supply multiple announce URLs, also use `--announce-tier`."
|
||||
long_help = "Use `ANNOUNCE` as the primary tracker announce URL. To supply multiple announce \
|
||||
URLs, also use `--announce-tier`."
|
||||
)]
|
||||
announce: Url,
|
||||
#[structopt(
|
||||
name = "ALLOW",
|
||||
long = "allow",
|
||||
help = "Use `ANNOUNCE` as the primary tracker announce URL.",
|
||||
long_help = "Use `ANNOUNCE` as the primary tracker announce URL. To supply multiple announce URLs, also use `--announce-tier`."
|
||||
long_help = "Use `ANNOUNCE` as the primary tracker announce URL. To supply multiple announce \
|
||||
URLs, also use `--announce-tier`."
|
||||
)]
|
||||
allowed_lints: Vec<Lint>,
|
||||
#[structopt(
|
||||
long = "announce-tier",
|
||||
name = "ANNOUNCE-TIER",
|
||||
help = "Add `ANNOUNCE-TIER` to list of tracker announce tiers.",
|
||||
long_help = "\
|
||||
Add `ANNOUNCE-TIER` to list of tracker announce tiers. Each instance adds a new tier. To add multiple trackers to a given tier, separate their announce URLs with commas:
|
||||
|
||||
`--announce-tier udp://example.com:80/announce,https://example.net:443/announce`
|
||||
|
||||
Announce tiers are stored in the `announce-list` key of the top-level metainfo dictionary as a list of lists of strings, as defined by BEP 12: Multitracker Metadata Extension.
|
||||
|
||||
Note: Many BitTorrent clients do not implement the behavior described in BEP 12. See the discussion here for more details: https://github.com/bittorrent/bittorrent.org/issues/82"
|
||||
long_help = "Add `ANNOUNCE-TIER` to list of tracker announce tiers. Each instance adds a new \
|
||||
tier. To add multiple trackers to a given tier, separate their announce URLs \
|
||||
with commas:\n\
|
||||
\n\
|
||||
`--announce-tier udp://example.com:80/announce,https://example.net:443/announce`
|
||||
\n\
|
||||
Announce tiers are stored in the `announce-list` key of the top-level metainfo \
|
||||
dictionary as a list of lists of strings, as defined by BEP 12: Multitracker \
|
||||
Metadata Extension.
|
||||
\n\
|
||||
Note: Many BitTorrent clients do not implement the behavior described in BEP \
|
||||
12. See the discussion here for more details: \
|
||||
https://github.com/bittorrent/bittorrent.org/issues/82"
|
||||
)]
|
||||
announce_tiers: Vec<String>,
|
||||
#[structopt(
|
||||
name = "COMMENT",
|
||||
long = "comment",
|
||||
help = "Include `COMMENT` in generated `.torrent` file.",
|
||||
long_help = "Include `COMMENT` in generated `.torrent` file. Stored under `comment` key of top-level metainfo dictionary."
|
||||
long_help = "Include `COMMENT` in generated `.torrent` file. Stored under `comment` key of \
|
||||
top-level metainfo dictionary."
|
||||
)]
|
||||
comment: Option<String>,
|
||||
#[structopt(
|
||||
name = "NODE",
|
||||
long = "dht-node",
|
||||
help = "Add DHT bootstrap node `NODE` to torrent. `NODE` should be in the form `HOST:PORT`.",
|
||||
long_help = "Add DHT bootstrap node `NODE` to torrent. `NODE` should be in the form `HOST:PORT`, where `HOST` is a domain name, an IPv4 address, or an IPv6 address surrounded by brackets. May be given more than once to add multiple bootstrap nodes. Examples:
|
||||
long_help = "Add DHT bootstrap node `NODE` to torrent. `NODE` should be in the form \
|
||||
`HOST:PORT`, where `HOST` is a domain name, an IPv4 address, or an IPv6 address \
|
||||
surrounded by brackets. May be given more than once to add multiple bootstrap \
|
||||
nodes. Examples:
|
||||
`--dht-node router.example.com:1337`
|
||||
`--dht-node 203.0.113.0:2290`
|
||||
`--dht-node [2001:db8:4275:7920:6269:7463:6f69:6e21]:8832`"
|
||||
|
@ -56,7 +67,8 @@ Note: Many BitTorrent clients do not implement the behavior described in BEP 12.
|
|||
#[structopt(
|
||||
name = "FOLLOW-SYMLINKS",
|
||||
long = "follow-symlinks",
|
||||
help = "Follow symlinks in torrent input. By default, symlinks to files and directories are not included in torrent contents."
|
||||
help = "Follow symlinks in torrent input. By default, symlinks to files and directories are \
|
||||
not included in torrent contents."
|
||||
)]
|
||||
follow_symlinks: bool,
|
||||
#[structopt(
|
||||
|
@ -68,13 +80,15 @@ Note: Many BitTorrent clients do not implement the behavior described in BEP 12.
|
|||
#[structopt(
|
||||
name = "GLOB",
|
||||
long = "glob",
|
||||
help = "Include or exclude files that match `GLOB`. Multiple glob may be provided, with the last one taking precedence. Precede a glob with a ! to exclude it."
|
||||
help = "Include or exclude files that match `GLOB`. Multiple glob may be provided, with the \
|
||||
last one taking precedence. Precede a glob with a ! to exclude it."
|
||||
)]
|
||||
globs: Vec<String>,
|
||||
#[structopt(
|
||||
name = "INCLUDE-HIDDEN",
|
||||
long = "include-hidden",
|
||||
help = "Include hidden files that would otherwise be skipped, such as files that start with a `.`, and files hidden by file attributes on macOS and Windows."
|
||||
help = "Include hidden files that would otherwise be skipped, such as files that start with a \
|
||||
`.`, and files hidden by file attributes on macOS and Windows."
|
||||
)]
|
||||
include_hidden: bool,
|
||||
#[structopt(
|
||||
|
@ -87,15 +101,19 @@ Note: Many BitTorrent clients do not implement the behavior described in BEP 12.
|
|||
name = "INPUT",
|
||||
long = "input",
|
||||
help = "Read torrent contents from `INPUT`.",
|
||||
long_help = "Read torrent contents from `INPUT`. If `INPUT` is a file, torrent will be a single-file torrent, otherwise if `INPUT` is a directory, torrent will be a multi-file torrent.",
|
||||
long_help = "Read torrent contents from `INPUT`. If `INPUT` is a file, torrent will be a \
|
||||
single-file torrent, otherwise if `INPUT` is a directory, torrent will be a \
|
||||
multi-file torrent.",
|
||||
parse(from_os_str)
|
||||
)]
|
||||
input: PathBuf,
|
||||
#[structopt(
|
||||
name = "MD5SUM",
|
||||
long = "md5sum",
|
||||
help = "Include MD5 checksum of each file in the torrent. N.B. MD5 is cryptographically broken and only suitable for safeguarding against accidental corruption.",
|
||||
long_help = "Include MD5 checksum of each file in the torrent. N.B. MD5 is cryptographically broken and only suitable for checking for accidental corruption."
|
||||
help = "Include MD5 checksum of each file in the torrent. N.B. MD5 is cryptographically \
|
||||
broken and only suitable for safeguarding against accidental corruption.",
|
||||
long_help = "Include MD5 checksum of each file in the torrent. N.B. MD5 is cryptographically \
|
||||
broken and only suitable for checking for accidental corruption."
|
||||
)]
|
||||
md5sum: bool,
|
||||
#[structopt(
|
||||
|
@ -120,13 +138,15 @@ Note: Many BitTorrent clients do not implement the behavior described in BEP 12.
|
|||
name = "OPEN",
|
||||
long = "open",
|
||||
help = "Open `.torrent` file after creation",
|
||||
long_help = "Open `.torrent` file after creation. Uses `xdg-open`, `gnome-open`, or `kde-open` on Linux; `open` on macOS; and `cmd /C start on Windows"
|
||||
long_help = "Open `.torrent` file after creation. Uses `xdg-open`, `gnome-open`, or \
|
||||
`kde-open` on Linux; `open` on macOS; and `cmd /C start on Windows"
|
||||
)]
|
||||
open: bool,
|
||||
#[structopt(
|
||||
name = "OUTPUT",
|
||||
long = "output",
|
||||
help = "Save `.torrent` file to `OUTPUT`, or `-` for standard output. Defaults to `$INPUT.torrent`.",
|
||||
help = "Save `.torrent` file to `OUTPUT`, or `-` for standard output. Defaults to \
|
||||
`$INPUT.torrent`.",
|
||||
parse(from_os_str)
|
||||
)]
|
||||
output: Option<Target>,
|
||||
|
@ -134,21 +154,27 @@ Note: Many BitTorrent clients do not implement the behavior described in BEP 12.
|
|||
name = "PIECE-LENGTH",
|
||||
long = "piece-length",
|
||||
help = "Set piece length to `PIECE-LENGTH` bytes.",
|
||||
long_help = "Set piece length to `PIECE-LENGTH` bytes. Accepts SI units, e.g. kib, mib, and gib."
|
||||
long_help = "Set piece length to `PIECE-LENGTH` bytes. Accepts SI units, e.g. kib, mib, and \
|
||||
gib."
|
||||
)]
|
||||
piece_length: Option<Bytes>,
|
||||
#[structopt(
|
||||
name = "PRIVATE",
|
||||
long = "private",
|
||||
help = "Set the `private` flag.",
|
||||
long_help = "Set the `private` flag. Torrent clients that understand the flag and participate in the swarm of a torrent with the flag set will only announce themselves to the announce URLs included in the torrent, and will not use other peer discovery mechanisms, such as the DHT or local peer discovery. See BEP 27: Private Torrents for more information."
|
||||
long_help = "Set the `private` flag. Torrent clients that understand the flag and participate \
|
||||
in the swarm of a torrent with the flag set will only announce themselves to the \
|
||||
announce URLs included in the torrent, and will not use other peer discovery \
|
||||
mechanisms, such as the DHT or local peer discovery. See BEP 27: Private \
|
||||
Torrents for more information."
|
||||
)]
|
||||
private: bool,
|
||||
#[structopt(
|
||||
name = "SOURCE",
|
||||
long = "source",
|
||||
help = "Include `SOURCE` in generated `.torrent` file.",
|
||||
long_help = "Include `SOURCe` in generated `.torrent` file. Stored under `info.source` key of metainfo dictionary."
|
||||
long_help = "Include `SOURCe` in generated `.torrent` file. Stored under `info.source` key of \
|
||||
metainfo dictionary."
|
||||
)]
|
||||
source: Option<String>,
|
||||
}
|
||||
|
@ -1230,6 +1256,7 @@ mod tests {
|
|||
fs::write(dir.join("h"), "hij").unwrap();
|
||||
env.run().unwrap();
|
||||
let have = env.out();
|
||||
#[rustfmt::skip]
|
||||
let want = format!(
|
||||
" Name foo
|
||||
Created By {}
|
||||
|
|
|
@ -12,7 +12,8 @@ pub(crate) struct Stats {
|
|||
long = "limit",
|
||||
short = "l",
|
||||
help = "Stop after processing the first `COUNT` torrents.",
|
||||
long_help = "Stop after processing the first `COUNT` torrents. Useful when processing large collections of `.torrent` files."
|
||||
long_help = "Stop after processing the first `COUNT` torrents. Useful when processing large \
|
||||
collections of `.torrent` files."
|
||||
)]
|
||||
limit: Option<u64>,
|
||||
#[structopt(
|
||||
|
@ -20,8 +21,12 @@ pub(crate) struct Stats {
|
|||
long = "extract-pattern",
|
||||
short = "e",
|
||||
help = "Extract and display values from key paths that match `REGEX`.",
|
||||
long_help = "\
|
||||
Extract and display values under key paths that match `REGEX`. Subkeys of a bencodeded dictionary are delimited by `/`, and values of a bencoded list are delmited by `*`. For example, given the following bencoded dictionary `{\"foo\": [{\"bar\": {\"baz\": 2}}]}`, the value `2`'s key path will be `foo*bar/baz`. The value `2` would be displayed if any of `bar`, `foo[*]bar/baz`, or `foo.*baz` were passed to `--extract-pattern."
|
||||
long_help = "Extract and display values under key paths that match `REGEX`. Subkeys of a \
|
||||
bencodeded dictionary are delimited by `/`, and values of a bencoded list are \
|
||||
delmited by `*`. For example, given the following bencoded dictionary `{\"foo\": \
|
||||
[{\"bar\": {\"baz\": 2}}]}`, the value `2`'s key path will be `foo*bar/baz`. The \
|
||||
value `2` would be displayed if any of `bar`, `foo[*]bar/baz`, or `foo.*baz` \
|
||||
were passed to `--extract-pattern."
|
||||
)]
|
||||
extract_patterns: Vec<Regex>,
|
||||
#[structopt(
|
||||
|
@ -29,7 +34,8 @@ Extract and display values under key paths that match `REGEX`. Subkeys of a benc
|
|||
long = "input",
|
||||
short = "i",
|
||||
help = "Search `INPUT` for torrents.",
|
||||
long_help = "Search `INPUT` for torrents. May be a directory to search or a single torrent file.",
|
||||
long_help = "Search `INPUT` for torrents. May be a directory to search or a single torrent \
|
||||
file.",
|
||||
parse(from_os_str)
|
||||
)]
|
||||
input: PathBuf,
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
// Constraints:
|
||||
// - Decreasing piece length increases protocol overhead.
|
||||
// - Decreasing piece length increases torrent metainfo size.
|
||||
// - Increasing piece length increases the amount of data that must be
|
||||
// thrown away in case of corruption.
|
||||
// - Increasing piece length increases the amount of data that must be thrown
|
||||
// away in case of corruption.
|
||||
// - Increasing piece length increases the amount of data that must be
|
||||
// downloaded before it can be verified and uploaded to other peers.
|
||||
// - Decreasing piece length increases the proportion of disk seeks to
|
||||
// disk reads. This can be an issue for spinning disks.
|
||||
// - The BitTorrent v2 specification requires that piece sizes be
|
||||
// larger than 16 KiB.
|
||||
// - Decreasing piece length increases the proportion of disk seeks to disk
|
||||
// reads. This can be an issue for spinning disks.
|
||||
// - The BitTorrent v2 specification requires that piece sizes be larger than 16
|
||||
// KiB.
|
||||
//
|
||||
// These constraints could probably be exactly defined and optimized
|
||||
// using an integer programming solver, but instead we just copy what
|
||||
|
|
|
@ -30,8 +30,7 @@ impl PlatformInterface for Platform {
|
|||
}
|
||||
|
||||
fn hidden(path: &Path) -> Result<bool, Error> {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
use std::{ffi::CString, mem};
|
||||
use std::{ffi::CString, mem, os::unix::ffi::OsStrExt};
|
||||
|
||||
const HIDDEN_MASK_MAC: u32 = 0x0000_8000;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user