1
Fork 0

Compare commits

...

8 Commits
0.1.0 ... main

Author SHA1 Message Date
Bauke f419552c96
Version 0.1.2! 2024-01-25 19:14:06 +01:00
Bauke 146eba19ef
Update dependencies. 2024-01-25 18:52:13 +01:00
Bauke 29dd410b3b
Move global lints to Cargo.toml. 2024-01-25 18:48:26 +01:00
Bauke 357c2bbfbf
Add Nix flake and direnv files. 2024-01-25 18:43:51 +01:00
Bauke 962a45a0f3
Remove eye from source code. 2022-09-23 17:55:40 +02:00
Bauke b84f4298f7
Fix excess Unicode character. 2022-09-23 17:53:46 +02:00
Bauke 67ebf317cb
Version 0.1.1! 2022-09-23 17:44:18 +02:00
Bauke 527a61f0ec
Rewrite readme, add license header, move to Gitea. 2022-09-23 17:40:30 +02:00
11 changed files with 630 additions and 487 deletions

3
.envrc Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
use flake

6
.gitignore vendored
View File

@ -1,6 +1,4 @@
# Generated by Cargo
.direnv/
coverage/
debug/
target/
# Code coverage results
coverage/

818
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
[package]
name = "select-html"
description = "A command-line tool to extract HTML using CSS selectors"
repository = "https://github.com/Bauke/select-html"
description = "Extract HTML using CSS selectors in the command-line."
repository = "https://git.bauke.xyz/Bauke/select-html"
license = "AGPL-3.0-or-later"
version = "0.1.0"
version = "0.1.2"
authors = ["Bauke <me@bauke.xyz>"]
edition = "2021"
@ -11,14 +11,21 @@ edition = "2021"
name = "select-html"
path = "source/main.rs"
[lints.clippy]
missing_docs_in_private_items = "warn"
[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"
[dependencies]
color-eyre = "0.6.2"
scraper = "0.13.0"
scraper = "0.18.1"
[dependencies.clap]
features = ["derive"]
version = "3.2.20"
version = "4.4.18"
[dev-dependencies]
assert_cmd = "2.0.4"
test-case = "2.2.1"
assert_cmd = "2.0.13"
test-case = "3.3.1"

View File

@ -1,33 +1,21 @@
[tasks.fmt]
command = "cargo"
args = ["fmt", "${@}"]
[tasks.check]
command = "cargo"
args = ["check", "${@}"]
[tasks.clippy]
command = "cargo"
args = ["clippy", "${@}"]
[tasks.test]
command = "cargo"
args = ["test", "${@}"]
[tasks.doc]
command = "cargo"
args = ["doc", "${@}"]
[tasks.build]
command = "cargo"
args = ["build", "${@}"]
# Do a full check of everything.
[tasks.complete-check]
dependencies = ["fmt", "check", "clippy", "test", "doc", "build"]
dependencies = [
"format",
"spellcheck",
"check",
"clippy",
"test",
"code-coverage",
"docs",
"build",
"audit-flow",
"outdated-flow",
]
# Run cargo-tarpaulin and output the test coverage.
[tasks.code-coverage]
workspace = false
install_crate = "cargo-tarpaulin"
command = "cargo"
args = [
"tarpaulin",
@ -35,5 +23,10 @@ args = [
"--out=html",
"--output-dir=coverage",
"--skip-clean",
"--target-dir=target/tarpaulin"
"--target-dir=target/tarpaulin",
]
# Do a source code spellcheck.
[tasks.spellcheck]
clear = true
command = "typos"

View File

@ -1,8 +1,28 @@
# select-html
# Select 👁 HTML
> A command-line tool to extract HTML using CSS selectors.
> **Extract HTML using CSS selectors in the command-line.**
*AGPL-3.0-or-later*
## Features
* Input HTML using stdin or a file.
* Output full elements, inner text or attribute values.
* Trim excess whitespace from output.
## Installation
### Cargo
With a working [Rust and Cargo](https://www.rust-lang.org/learn/get-started) installation, you can install `select-html` from [Crates.io](https://crates.io/crates/select-html).
```
cargo install select-html
```
### Binaries
Precompiled `x86_64-unknown-linux-gnu` binaries are available on the [Releases page](https://git.bauke.xyz/Bauke/select-html/releases).
## Examples
```sh
# Use stdin to pipe HTML to select-html.
@ -21,14 +41,7 @@ select-html '.example' --text
select-html '[property^="og:"]' -a 'property' -a 'content'
```
## Installation
You can download a precompiled executable from the [GitHub Releases] page, or install via [crates.io] (`cargo install select-html`).
[GitHub Releases]: https://github.com/Bauke/select-html/releases
[crates.io]: https://crates.io/crates/select-html
## `--help`
## Usage
```
USAGE:
@ -46,3 +59,15 @@ OPTIONS:
--trim Trim whitespace from selected items
-V, --version Print version information
```
## Development
With [Nix flakes](https://nixos.wiki/wiki/Flakes) and [direnv](https://direnv.net/) installed and enabled, all the required dependencies are automatically loaded from [`shell.nix`](./shell.nix). Then [cargo-make](https://sagiegurari.github.io/cargo-make/) can be used to build, deploy and lint the code. The available tasks are all described in the [`Makefile.toml`](Makefile.toml) configuration.
## Feedback
Found a problem or want to request a new feature? Email [me@bauke.xyz](mailto:me@bauke.xyz) and I'll see what I can do for you.
## License
Distributed under the [AGPL-3.0-or-later](https://spdx.org/licenses/AGPL-3.0-or-later.html) license, see [LICENSE](https://git.bauke.xyz/Bauke/select-html/src/branch/main/LICENSE) for more information.

128
flake.lock Normal file
View File

@ -0,0 +1,128 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1681202837,
"narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "cfacdce06f30d2b68473a46042957675eebb3401",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1706006310,
"narHash": "sha256-nDPz0fj0IFcDhSTlXBU2aixcnGs2Jm4Zcuoj0QtmiXQ=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b43bb235efeab5324c5e486882ef46749188eee2",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1681358109,
"narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "96ba1c52e54e74c3197f4d43026b3f3d92e83ff9",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1706149103,
"narHash": "sha256-Me28A0tAb1EzZIozfi31+hnsQIaYU0HXaMPWCe+zByc=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "493cc67d5e9f1b298241b8d92aa06883296acc3f",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

17
flake.nix Normal file
View File

@ -0,0 +1,17 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs { inherit system overlays; };
in
{
devShells.default = import ./shell.nix { inherit pkgs; };
}
);
}

3
rustup-toolchain.toml Normal file
View File

@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
components = ["cargo", "clippy", "rustfmt", "rust-src"]

18
shell.nix Normal file
View File

@ -0,0 +1,18 @@
{ pkgs ? import <nixpkgs> { } }:
with pkgs;
let
rustup-toolchain = rust-bin.fromRustupToolchainFile ./rustup-toolchain.toml;
in
mkShell rec {
packages = [
cargo-audit
cargo-edit
cargo-make
cargo-outdated
cargo-tarpaulin
rustup-toolchain
typos
];
}

View File

@ -1,9 +1,6 @@
//! # select-html
//! # Select HTML
//!
//! > A command-line tool to extract HTML using CSS selectors
#![forbid(unsafe_code)]
#![warn(missing_docs, clippy::missing_docs_in_private_items)]
//! > **Extract HTML using CSS selectors in the command-line.**
use std::{
fs::File,
@ -27,7 +24,7 @@ pub struct Args {
pub attribute: Vec<String>,
/// A HTML file to read, if not specified stdin will be used instead.
#[clap(long, parse(from_os_str))]
#[clap(long)]
pub file: Option<PathBuf>,
/// The CSS selector to use.