├── .envrc ├── .github └── workflows │ └── unit-tests.yml ├── .gitignore ├── .reuse └── dep5 ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── LICENSES ├── AGPL-3.0-only.txt ├── CC-BY-4.0.txt └── CC-BY-NC-SA-4.0.txt ├── README.md ├── benches └── basic_bench.rs ├── cliff.toml ├── doc ├── ARCHITECTURE.org ├── img │ ├── config-struct-nested.png │ ├── config-struct-nested.png.license │ ├── config-struct-store.png │ ├── config-struct-store.png.license │ ├── config-struct-vec.png │ └── config-struct-vec.png.license └── roadmap.org ├── flake.lock ├── flake.nix ├── rust-toolchain.toml ├── src ├── cli.rs ├── git.rs ├── lib.rs.old ├── main.rs ├── settings.rs ├── test │ └── config.yaml ├── utils.rs └── utils │ ├── dir.rs │ └── strings.rs ├── tests └── main.rs └── treefmt.nix /.envrc: -------------------------------------------------------------------------------- 1 | if has nix; then 2 | use flake . 3 | fi 4 | -------------------------------------------------------------------------------- /.github/workflows/unit-tests.yml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | name: Unit tests 7 | 8 | on: 9 | push: 10 | branches: [ main ] 11 | paths: 12 | - '.github/workflows/*' 13 | - 'src/**' 14 | - 'Cargo.*' 15 | - build.rs 16 | pull_request: 17 | branches: [ main ] 18 | paths: 19 | - '.github/workflows/*' 20 | - 'src/**' 21 | - 'Cargo.*' 22 | - build.rs 23 | 24 | env: 25 | CARGO_TERM_COLOR: always 26 | 27 | jobs: 28 | unit-tests: 29 | runs-on: ${{ matrix.os }} 30 | 31 | continue-on-error: ${{ matrix.rust == 'nightly' }} 32 | 33 | strategy: 34 | matrix: 35 | os: [ubuntu-latest, macos-latest] 36 | rust: [1.71.0, stable, beta, nightly] 37 | 38 | steps: 39 | - name: Checkout repository 40 | uses: actions/checkout@v3 41 | 42 | - name: Install Rust toolchain 43 | uses: dtolnay/rust-toolchain@v1 44 | with: 45 | toolchain: ${{ matrix.rust }} 46 | 47 | - name: Install cargo-hack 48 | run: cargo install cargo-hack@0.5.27 49 | 50 | - name: Run unit tests 51 | run: cargo hack test --feature-powerset 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | /target 7 | /src/test/test 8 | /src/test/test.yaml 9 | /result 10 | 11 | .direnv 12 | .pre-commit-config.yaml 13 | -------------------------------------------------------------------------------- /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: rime 3 | Upstream-Contact: Christina Sørensen 4 | Source: 5 | 6 | # Sample paragraph, commented out: 7 | # 8 | # Files: src/* 9 | # Copyright: $YEAR $NAME <$CONTACT> 10 | # License: ... 11 | 12 | Files: flake.lock 13 | Copyright: 2023 Christina Sørensen 14 | License: AGPL-3.0-only 15 | 16 | Files: Cargo.lock 17 | Copyright: 2023 Christina Sørensen 18 | License: AGPL-3.0-only 19 | 20 | Files: .envrc 21 | Copyright: 2023 Christina Sørensen 22 | License: AGPL-3.0-only 23 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | # Changelog 9 | 10 | All notable changes to this project will be documented in this file. 11 | 12 | ## [0.2.0] - 2023-07-07 13 | 14 | ### Bug Fixes 15 | 16 | - Made categories with only links possible 17 | 18 | ### Features 19 | 20 | - [**breaking**] Put links in categories 21 | 22 | ### Miscellaneous Tasks 23 | 24 | - Filled out Cargo.toml 25 | - Added test.yaml to gitignore 26 | - Fixed up code, roadmap for bump 27 | 28 | ### Refactor 29 | 30 | - Simple code quality changes 31 | 32 | ### Testing 33 | 34 | - Refactored testing, added tests dir 35 | 36 | ## [0.1.2] - 2023-07-03 37 | 38 | ### Features 39 | 40 | - Implemented quiet flag 41 | 42 | ### Miscellaneous Tasks 43 | 44 | - Bump to v0.1.2 45 | 46 | ## [0.1.1] - 2023-07-03 47 | 48 | ### Bug Fixes 49 | 50 | - Fixed help formatting 51 | 52 | ### Documentation 53 | 54 | - Added asciinema demo 55 | 56 | ### Features 57 | 58 | - Added no-emoji flag 59 | 60 | ### Miscellaneous Tasks 61 | 62 | - Bump v0.1.0, housekeeping, #8 from cafkafk/dev 63 | - Bump to v0.1.1 64 | 65 | ## [0.1.0] - 2023-07-03 66 | 67 | ### Documentation 68 | 69 | - Changed roadmap 70 | - Updated roadmap 71 | 72 | ### Features 73 | 74 | - Implemented CoC flag 75 | - Quiet flag 76 | - Made SUCCESS/FAILURE emoji const 77 | - Added flag no-emoji 78 | 79 | ### Miscellaneous Tasks 80 | 81 | - Bump to 0.0.7 #7 from cafkafk/dev 82 | - Bump v0.1.0, housekeeping 83 | 84 | ### Refactor 85 | 86 | - Made code more idiomatic 87 | 88 | ## [0.0.7] - 2023-07-02 89 | 90 | ### Bug Fixes 91 | 92 | - Changed config.yaml location 93 | - Increased scope of push field 94 | - Remove potentially destructive operaton 95 | - Fixed mini-license typos 96 | - Fixed testing with hashmap arch 97 | - Spinner on all repoactions 98 | - Fixed commit in quick 99 | - [**breaking**] Fixed quick, fast messages 100 | - Fixed commit with editor regression 101 | 102 | ### Documentation 103 | 104 | - Architectural Overview 105 | - Moved charts to doc/img 106 | - Update image locations 107 | - Moved ARCHITECTURE.md to doc/ 108 | - Added some documentation 109 | - Added roadmap 110 | - Added git cliff config 111 | 112 | ### Features 113 | 114 | - Started flakification 115 | - Added nix flake #5 116 | - [**breaking**] Add push field 117 | - [**breaking**] Add repo flags 118 | - [**breaking**] Implemented naive categories 119 | - Started work on using spinners 120 | - Added pull flag 121 | - React to exit code of git 122 | - Started adding multi instruction logic 123 | - Added fast subcommand 124 | - Add Commit, Add flags 125 | - [**breaking**] Added Quick, Fast flags 126 | - Made category flags optional 127 | - Made categories.repo optional 128 | - Made repo flags optional 129 | 130 | ### Miscellaneous Tasks 131 | 132 | - Version bump to v0.0.3 133 | - Moved install scripts to ./bin 134 | - Merge 0.0.6 135 | - Merge 0.0.6 #6 from cafkafk/dev 136 | - Bump to 0.0.7 137 | 138 | ### Refactor 139 | 140 | - Fixed various clippy errors 141 | - Removed unused code from flake 142 | - Improved GitRepo assoc. function debug 143 | - Removed redundant line in Cargo.toml 144 | - Created on_all for config struct 145 | - Naive nested hashmap 146 | - Generic refactor 147 | 148 | ### Security 149 | 150 | - Removed atty dependency 151 | - Removed atty dependency 152 | 153 | ### Testing 154 | 155 | - Removed unused ./test dir 156 | 157 | ### WIP 158 | 159 | - Mvp flake working 160 | 161 | 162 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | # Contributor Covenant Code of Conduct 8 | 9 | ## Our Pledge 10 | 11 | We as members, contributors, and leaders pledge to make participation in our 12 | community a harassment-free experience for everyone, regardless of age, body 13 | size, visible or invisible disability, ethnicity, sex characteristics, gender 14 | identity and expression, level of experience, education, socio-economic status, 15 | nationality, personal appearance, race, caste, color, religion, or sexual 16 | identity and orientation. 17 | 18 | We pledge to act and interact in ways that contribute to an open, welcoming, 19 | diverse, inclusive, and healthy community. 20 | 21 | ## Our Standards 22 | 23 | Examples of behavior that contributes to a positive environment for our 24 | community include: 25 | 26 | * Demonstrating empathy and kindness toward other people 27 | * Being respectful of differing opinions, viewpoints, and experiences 28 | * Giving and gracefully accepting constructive feedback 29 | * Accepting responsibility and apologizing to those affected by our mistakes, 30 | and learning from the experience 31 | * Focusing on what is best not just for us as individuals, but for the overall 32 | community 33 | 34 | Examples of unacceptable behavior include: 35 | 36 | * The use of sexualized language or imagery, and sexual attention or advances of 37 | any kind 38 | * Trolling, insulting or derogatory comments, and personal or political attacks 39 | * Public or private harassment 40 | * Publishing others' private information, such as a physical or email address, 41 | without their explicit permission 42 | * Other conduct which could reasonably be considered inappropriate in a 43 | professional setting 44 | 45 | ## Enforcement Responsibilities 46 | 47 | Community leaders are responsible for clarifying and enforcing our standards of 48 | acceptable behavior and will take appropriate and fair corrective action in 49 | response to any behavior that they deem inappropriate, threatening, offensive, 50 | or harmful. 51 | 52 | Community leaders have the right and responsibility to remove, edit, or reject 53 | comments, commits, code, wiki edits, issues, and other contributions that are 54 | not aligned to this Code of Conduct, and will communicate reasons for moderation 55 | decisions when appropriate. 56 | 57 | ## Scope 58 | 59 | This Code of Conduct applies within all community spaces, and also applies when 60 | an individual is officially representing the community in public spaces. 61 | Examples of representing our community include using an official e-mail address, 62 | posting via an official social media account, or acting as an appointed 63 | representative at an online or offline event. 64 | 65 | ## Enforcement 66 | 67 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 68 | reported to the community leaders responsible for enforcement at: 69 | 70 | matrix: @cafkafk:nixos.dev 71 | 72 | All complaints will be reviewed and investigated promptly and fairly. 73 | 74 | All community leaders are obligated to respect the privacy and security of the 75 | reporter of any incident. 76 | 77 | ## Enforcement Guidelines 78 | 79 | Community leaders will follow these Community Impact Guidelines in determining 80 | the consequences for any action they deem in violation of this Code of Conduct: 81 | 82 | ### 1. Correction 83 | 84 | **Community Impact**: Use of inappropriate language or other behavior deemed 85 | unprofessional or unwelcome in the community. 86 | 87 | **Consequence**: A private, written warning from community leaders, providing 88 | clarity around the nature of the violation and an explanation of why the 89 | behavior was inappropriate. A public apology may be requested. 90 | 91 | ### 2. Warning 92 | 93 | **Community Impact**: A violation through a single incident or series of 94 | actions. 95 | 96 | **Consequence**: A warning with consequences for continued behavior. No 97 | interaction with the people involved, including unsolicited interaction with 98 | those enforcing the Code of Conduct, for a specified period of time. This 99 | includes avoiding interactions in community spaces as well as external channels 100 | like social media. Violating these terms may lead to a temporary or permanent 101 | ban. 102 | 103 | ### 3. Temporary Ban 104 | 105 | **Community Impact**: A serious violation of community standards, including 106 | sustained inappropriate behavior. 107 | 108 | **Consequence**: A temporary ban from any sort of interaction or public 109 | communication with the community for a specified period of time. No public or 110 | private interaction with the people involved, including unsolicited interaction 111 | with those enforcing the Code of Conduct, is allowed during this period. 112 | Violating these terms may lead to a permanent ban. 113 | 114 | ### 4. Permanent Ban 115 | 116 | **Community Impact**: Demonstrating a pattern of violation of community 117 | standards, including sustained inappropriate behavior, harassment of an 118 | individual, or aggression toward or disparagement of classes of individuals. 119 | 120 | **Consequence**: A permanent ban from any sort of public interaction within the 121 | community. 122 | 123 | ## Attribution 124 | 125 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 126 | version 2.1, available at 127 | [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. 128 | 129 | Community Impact Guidelines were inspired by 130 | [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. 131 | 132 | For answers to common questions about this code of conduct, see the FAQ at 133 | [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at 134 | [https://www.contributor-covenant.org/translations][translations]. 135 | 136 | [homepage]: https://www.contributor-covenant.org 137 | [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html 138 | [Mozilla CoC]: https://github.com/mozilla/diversity 139 | [FAQ]: https://www.contributor-covenant.org/faq 140 | [translations]: https://www.contributor-covenant.org/translations 141 | 142 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "1.1.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "anes" 16 | version = "0.1.6" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" 19 | 20 | [[package]] 21 | name = "anstream" 22 | version = "0.6.11" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" 25 | dependencies = [ 26 | "anstyle", 27 | "anstyle-parse", 28 | "anstyle-query", 29 | "anstyle-wincon", 30 | "colorchoice", 31 | "utf8parse", 32 | ] 33 | 34 | [[package]] 35 | name = "anstyle" 36 | version = "1.0.4" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" 39 | 40 | [[package]] 41 | name = "anstyle-parse" 42 | version = "0.2.3" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" 45 | dependencies = [ 46 | "utf8parse", 47 | ] 48 | 49 | [[package]] 50 | name = "anstyle-query" 51 | version = "1.0.2" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" 54 | dependencies = [ 55 | "windows-sys", 56 | ] 57 | 58 | [[package]] 59 | name = "anstyle-wincon" 60 | version = "3.0.2" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" 63 | dependencies = [ 64 | "anstyle", 65 | "windows-sys", 66 | ] 67 | 68 | [[package]] 69 | name = "autocfg" 70 | version = "1.1.0" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 73 | 74 | [[package]] 75 | name = "bitflags" 76 | version = "2.4.2" 77 | source = "registry+https://github.com/rust-lang/crates.io-index" 78 | checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" 79 | 80 | [[package]] 81 | name = "bumpalo" 82 | version = "3.14.0" 83 | source = "registry+https://github.com/rust-lang/crates.io-index" 84 | checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" 85 | 86 | [[package]] 87 | name = "cast" 88 | version = "0.3.0" 89 | source = "registry+https://github.com/rust-lang/crates.io-index" 90 | checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" 91 | 92 | [[package]] 93 | name = "cfg-if" 94 | version = "1.0.0" 95 | source = "registry+https://github.com/rust-lang/crates.io-index" 96 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 97 | 98 | [[package]] 99 | name = "ciborium" 100 | version = "0.2.2" 101 | source = "registry+https://github.com/rust-lang/crates.io-index" 102 | checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" 103 | dependencies = [ 104 | "ciborium-io", 105 | "ciborium-ll", 106 | "serde", 107 | ] 108 | 109 | [[package]] 110 | name = "ciborium-io" 111 | version = "0.2.2" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" 114 | 115 | [[package]] 116 | name = "ciborium-ll" 117 | version = "0.2.2" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" 120 | dependencies = [ 121 | "ciborium-io", 122 | "half", 123 | ] 124 | 125 | [[package]] 126 | name = "clap" 127 | version = "4.4.18" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" 130 | dependencies = [ 131 | "clap_builder", 132 | "clap_derive", 133 | ] 134 | 135 | [[package]] 136 | name = "clap_builder" 137 | version = "4.4.18" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" 140 | dependencies = [ 141 | "anstream", 142 | "anstyle", 143 | "clap_lex", 144 | "strsim", 145 | ] 146 | 147 | [[package]] 148 | name = "clap_derive" 149 | version = "4.4.7" 150 | source = "registry+https://github.com/rust-lang/crates.io-index" 151 | checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" 152 | dependencies = [ 153 | "heck", 154 | "proc-macro2", 155 | "quote", 156 | "syn 2.0.48", 157 | ] 158 | 159 | [[package]] 160 | name = "clap_lex" 161 | version = "0.6.0" 162 | source = "registry+https://github.com/rust-lang/crates.io-index" 163 | checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" 164 | 165 | [[package]] 166 | name = "clap_mangen" 167 | version = "0.2.17" 168 | source = "registry+https://github.com/rust-lang/crates.io-index" 169 | checksum = "4a7c2b01e5e779c19f46a94bbd398f33ae63b0f78c07108351fb4536845bb7fd" 170 | dependencies = [ 171 | "clap", 172 | "roff", 173 | ] 174 | 175 | [[package]] 176 | name = "colorchoice" 177 | version = "1.0.0" 178 | source = "registry+https://github.com/rust-lang/crates.io-index" 179 | checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" 180 | 181 | [[package]] 182 | name = "criterion" 183 | version = "0.5.1" 184 | source = "registry+https://github.com/rust-lang/crates.io-index" 185 | checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" 186 | dependencies = [ 187 | "anes", 188 | "cast", 189 | "ciborium", 190 | "clap", 191 | "criterion-plot", 192 | "is-terminal", 193 | "itertools", 194 | "num-traits", 195 | "once_cell", 196 | "oorandom", 197 | "plotters", 198 | "rayon", 199 | "regex", 200 | "serde", 201 | "serde_derive", 202 | "serde_json", 203 | "tinytemplate", 204 | "walkdir", 205 | ] 206 | 207 | [[package]] 208 | name = "criterion-plot" 209 | version = "0.5.0" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" 212 | dependencies = [ 213 | "cast", 214 | "itertools", 215 | ] 216 | 217 | [[package]] 218 | name = "crossbeam-deque" 219 | version = "0.8.5" 220 | source = "registry+https://github.com/rust-lang/crates.io-index" 221 | checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" 222 | dependencies = [ 223 | "crossbeam-epoch", 224 | "crossbeam-utils", 225 | ] 226 | 227 | [[package]] 228 | name = "crossbeam-epoch" 229 | version = "0.9.18" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" 232 | dependencies = [ 233 | "crossbeam-utils", 234 | ] 235 | 236 | [[package]] 237 | name = "crossbeam-utils" 238 | version = "0.8.19" 239 | source = "registry+https://github.com/rust-lang/crates.io-index" 240 | checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" 241 | 242 | [[package]] 243 | name = "crunchy" 244 | version = "0.2.2" 245 | source = "registry+https://github.com/rust-lang/crates.io-index" 246 | checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" 247 | 248 | [[package]] 249 | name = "either" 250 | version = "1.9.0" 251 | source = "registry+https://github.com/rust-lang/crates.io-index" 252 | checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" 253 | 254 | [[package]] 255 | name = "env_logger" 256 | version = "0.10.2" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" 259 | dependencies = [ 260 | "humantime", 261 | "is-terminal", 262 | "log", 263 | "regex", 264 | "termcolor", 265 | ] 266 | 267 | [[package]] 268 | name = "equivalent" 269 | version = "1.0.1" 270 | source = "registry+https://github.com/rust-lang/crates.io-index" 271 | checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" 272 | 273 | [[package]] 274 | name = "errno" 275 | version = "0.3.8" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" 278 | dependencies = [ 279 | "libc", 280 | "windows-sys", 281 | ] 282 | 283 | [[package]] 284 | name = "half" 285 | version = "2.3.1" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" 288 | dependencies = [ 289 | "cfg-if", 290 | "crunchy", 291 | ] 292 | 293 | [[package]] 294 | name = "hashbrown" 295 | version = "0.14.3" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" 298 | 299 | [[package]] 300 | name = "heck" 301 | version = "0.4.1" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" 304 | 305 | [[package]] 306 | name = "hermit-abi" 307 | version = "0.3.4" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" 310 | 311 | [[package]] 312 | name = "humantime" 313 | version = "2.1.0" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" 316 | 317 | [[package]] 318 | name = "indexmap" 319 | version = "2.1.0" 320 | source = "registry+https://github.com/rust-lang/crates.io-index" 321 | checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" 322 | dependencies = [ 323 | "equivalent", 324 | "hashbrown", 325 | ] 326 | 327 | [[package]] 328 | name = "is-terminal" 329 | version = "0.4.10" 330 | source = "registry+https://github.com/rust-lang/crates.io-index" 331 | checksum = "0bad00257d07be169d870ab665980b06cdb366d792ad690bf2e76876dc503455" 332 | dependencies = [ 333 | "hermit-abi", 334 | "rustix", 335 | "windows-sys", 336 | ] 337 | 338 | [[package]] 339 | name = "itertools" 340 | version = "0.10.5" 341 | source = "registry+https://github.com/rust-lang/crates.io-index" 342 | checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" 343 | dependencies = [ 344 | "either", 345 | ] 346 | 347 | [[package]] 348 | name = "itoa" 349 | version = "1.0.10" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" 352 | 353 | [[package]] 354 | name = "js-sys" 355 | version = "0.3.67" 356 | source = "registry+https://github.com/rust-lang/crates.io-index" 357 | checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" 358 | dependencies = [ 359 | "wasm-bindgen", 360 | ] 361 | 362 | [[package]] 363 | name = "lazy_static" 364 | version = "1.4.0" 365 | source = "registry+https://github.com/rust-lang/crates.io-index" 366 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 367 | 368 | [[package]] 369 | name = "libc" 370 | version = "0.2.152" 371 | source = "registry+https://github.com/rust-lang/crates.io-index" 372 | checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" 373 | 374 | [[package]] 375 | name = "linux-raw-sys" 376 | version = "0.4.13" 377 | source = "registry+https://github.com/rust-lang/crates.io-index" 378 | checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" 379 | 380 | [[package]] 381 | name = "log" 382 | version = "0.4.20" 383 | source = "registry+https://github.com/rust-lang/crates.io-index" 384 | checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" 385 | 386 | [[package]] 387 | name = "maplit" 388 | version = "1.0.2" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" 391 | 392 | [[package]] 393 | name = "memchr" 394 | version = "2.7.1" 395 | source = "registry+https://github.com/rust-lang/crates.io-index" 396 | checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" 397 | 398 | [[package]] 399 | name = "num-traits" 400 | version = "0.2.17" 401 | source = "registry+https://github.com/rust-lang/crates.io-index" 402 | checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" 403 | dependencies = [ 404 | "autocfg", 405 | ] 406 | 407 | [[package]] 408 | name = "once_cell" 409 | version = "1.19.0" 410 | source = "registry+https://github.com/rust-lang/crates.io-index" 411 | checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 412 | 413 | [[package]] 414 | name = "oorandom" 415 | version = "11.1.3" 416 | source = "registry+https://github.com/rust-lang/crates.io-index" 417 | checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" 418 | 419 | [[package]] 420 | name = "plotters" 421 | version = "0.3.5" 422 | source = "registry+https://github.com/rust-lang/crates.io-index" 423 | checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" 424 | dependencies = [ 425 | "num-traits", 426 | "plotters-backend", 427 | "plotters-svg", 428 | "wasm-bindgen", 429 | "web-sys", 430 | ] 431 | 432 | [[package]] 433 | name = "plotters-backend" 434 | version = "0.3.5" 435 | source = "registry+https://github.com/rust-lang/crates.io-index" 436 | checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" 437 | 438 | [[package]] 439 | name = "plotters-svg" 440 | version = "0.3.5" 441 | source = "registry+https://github.com/rust-lang/crates.io-index" 442 | checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" 443 | dependencies = [ 444 | "plotters-backend", 445 | ] 446 | 447 | [[package]] 448 | name = "pretty_env_logger" 449 | version = "0.5.0" 450 | source = "registry+https://github.com/rust-lang/crates.io-index" 451 | checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" 452 | dependencies = [ 453 | "env_logger", 454 | "log", 455 | ] 456 | 457 | [[package]] 458 | name = "proc-macro2" 459 | version = "1.0.78" 460 | source = "registry+https://github.com/rust-lang/crates.io-index" 461 | checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" 462 | dependencies = [ 463 | "unicode-ident", 464 | ] 465 | 466 | [[package]] 467 | name = "quote" 468 | version = "1.0.35" 469 | source = "registry+https://github.com/rust-lang/crates.io-index" 470 | checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" 471 | dependencies = [ 472 | "proc-macro2", 473 | ] 474 | 475 | [[package]] 476 | name = "rayon" 477 | version = "1.8.1" 478 | source = "registry+https://github.com/rust-lang/crates.io-index" 479 | checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" 480 | dependencies = [ 481 | "either", 482 | "rayon-core", 483 | ] 484 | 485 | [[package]] 486 | name = "rayon-core" 487 | version = "1.12.1" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" 490 | dependencies = [ 491 | "crossbeam-deque", 492 | "crossbeam-utils", 493 | ] 494 | 495 | [[package]] 496 | name = "regex" 497 | version = "1.10.3" 498 | source = "registry+https://github.com/rust-lang/crates.io-index" 499 | checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" 500 | dependencies = [ 501 | "aho-corasick", 502 | "memchr", 503 | "regex-automata", 504 | "regex-syntax", 505 | ] 506 | 507 | [[package]] 508 | name = "regex-automata" 509 | version = "0.4.5" 510 | source = "registry+https://github.com/rust-lang/crates.io-index" 511 | checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" 512 | dependencies = [ 513 | "aho-corasick", 514 | "memchr", 515 | "regex-syntax", 516 | ] 517 | 518 | [[package]] 519 | name = "regex-syntax" 520 | version = "0.8.2" 521 | source = "registry+https://github.com/rust-lang/crates.io-index" 522 | checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" 523 | 524 | [[package]] 525 | name = "relative-path" 526 | version = "1.9.2" 527 | source = "registry+https://github.com/rust-lang/crates.io-index" 528 | checksum = "e898588f33fdd5b9420719948f9f2a32c922a246964576f71ba7f24f80610fbc" 529 | 530 | [[package]] 531 | name = "roff" 532 | version = "0.2.1" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" 535 | 536 | [[package]] 537 | name = "rustix" 538 | version = "0.38.30" 539 | source = "registry+https://github.com/rust-lang/crates.io-index" 540 | checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" 541 | dependencies = [ 542 | "bitflags", 543 | "errno", 544 | "libc", 545 | "linux-raw-sys", 546 | "windows-sys", 547 | ] 548 | 549 | [[package]] 550 | name = "rustversion" 551 | version = "1.0.14" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" 554 | 555 | [[package]] 556 | name = "ryu" 557 | version = "1.0.16" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" 560 | 561 | [[package]] 562 | name = "same-file" 563 | version = "1.0.6" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 566 | dependencies = [ 567 | "winapi-util", 568 | ] 569 | 570 | [[package]] 571 | name = "seidr" 572 | version = "0.2.0" 573 | dependencies = [ 574 | "clap", 575 | "clap_mangen", 576 | "criterion", 577 | "log", 578 | "pretty_env_logger", 579 | "relative-path", 580 | "serde", 581 | "serde_yaml", 582 | "spinners", 583 | ] 584 | 585 | [[package]] 586 | name = "serde" 587 | version = "1.0.196" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" 590 | dependencies = [ 591 | "serde_derive", 592 | ] 593 | 594 | [[package]] 595 | name = "serde_derive" 596 | version = "1.0.196" 597 | source = "registry+https://github.com/rust-lang/crates.io-index" 598 | checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" 599 | dependencies = [ 600 | "proc-macro2", 601 | "quote", 602 | "syn 2.0.48", 603 | ] 604 | 605 | [[package]] 606 | name = "serde_json" 607 | version = "1.0.112" 608 | source = "registry+https://github.com/rust-lang/crates.io-index" 609 | checksum = "4d1bd37ce2324cf3bf85e5a25f96eb4baf0d5aa6eba43e7ae8958870c4ec48ed" 610 | dependencies = [ 611 | "itoa", 612 | "ryu", 613 | "serde", 614 | ] 615 | 616 | [[package]] 617 | name = "serde_yaml" 618 | version = "0.9.30" 619 | source = "registry+https://github.com/rust-lang/crates.io-index" 620 | checksum = "b1bf28c79a99f70ee1f1d83d10c875d2e70618417fda01ad1785e027579d9d38" 621 | dependencies = [ 622 | "indexmap", 623 | "itoa", 624 | "ryu", 625 | "serde", 626 | "unsafe-libyaml", 627 | ] 628 | 629 | [[package]] 630 | name = "spinners" 631 | version = "4.1.1" 632 | source = "registry+https://github.com/rust-lang/crates.io-index" 633 | checksum = "a0ef947f358b9c238923f764c72a4a9d42f2d637c46e059dbd319d6e7cfb4f82" 634 | dependencies = [ 635 | "lazy_static", 636 | "maplit", 637 | "strum", 638 | ] 639 | 640 | [[package]] 641 | name = "strsim" 642 | version = "0.10.0" 643 | source = "registry+https://github.com/rust-lang/crates.io-index" 644 | checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" 645 | 646 | [[package]] 647 | name = "strum" 648 | version = "0.24.1" 649 | source = "registry+https://github.com/rust-lang/crates.io-index" 650 | checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" 651 | dependencies = [ 652 | "strum_macros", 653 | ] 654 | 655 | [[package]] 656 | name = "strum_macros" 657 | version = "0.24.3" 658 | source = "registry+https://github.com/rust-lang/crates.io-index" 659 | checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" 660 | dependencies = [ 661 | "heck", 662 | "proc-macro2", 663 | "quote", 664 | "rustversion", 665 | "syn 1.0.109", 666 | ] 667 | 668 | [[package]] 669 | name = "syn" 670 | version = "1.0.109" 671 | source = "registry+https://github.com/rust-lang/crates.io-index" 672 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 673 | dependencies = [ 674 | "proc-macro2", 675 | "quote", 676 | "unicode-ident", 677 | ] 678 | 679 | [[package]] 680 | name = "syn" 681 | version = "2.0.48" 682 | source = "registry+https://github.com/rust-lang/crates.io-index" 683 | checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" 684 | dependencies = [ 685 | "proc-macro2", 686 | "quote", 687 | "unicode-ident", 688 | ] 689 | 690 | [[package]] 691 | name = "termcolor" 692 | version = "1.4.1" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" 695 | dependencies = [ 696 | "winapi-util", 697 | ] 698 | 699 | [[package]] 700 | name = "tinytemplate" 701 | version = "1.2.1" 702 | source = "registry+https://github.com/rust-lang/crates.io-index" 703 | checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" 704 | dependencies = [ 705 | "serde", 706 | "serde_json", 707 | ] 708 | 709 | [[package]] 710 | name = "unicode-ident" 711 | version = "1.0.12" 712 | source = "registry+https://github.com/rust-lang/crates.io-index" 713 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 714 | 715 | [[package]] 716 | name = "unsafe-libyaml" 717 | version = "0.2.10" 718 | source = "registry+https://github.com/rust-lang/crates.io-index" 719 | checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" 720 | 721 | [[package]] 722 | name = "utf8parse" 723 | version = "0.2.1" 724 | source = "registry+https://github.com/rust-lang/crates.io-index" 725 | checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" 726 | 727 | [[package]] 728 | name = "walkdir" 729 | version = "2.4.0" 730 | source = "registry+https://github.com/rust-lang/crates.io-index" 731 | checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" 732 | dependencies = [ 733 | "same-file", 734 | "winapi-util", 735 | ] 736 | 737 | [[package]] 738 | name = "wasm-bindgen" 739 | version = "0.2.90" 740 | source = "registry+https://github.com/rust-lang/crates.io-index" 741 | checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" 742 | dependencies = [ 743 | "cfg-if", 744 | "wasm-bindgen-macro", 745 | ] 746 | 747 | [[package]] 748 | name = "wasm-bindgen-backend" 749 | version = "0.2.90" 750 | source = "registry+https://github.com/rust-lang/crates.io-index" 751 | checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" 752 | dependencies = [ 753 | "bumpalo", 754 | "log", 755 | "once_cell", 756 | "proc-macro2", 757 | "quote", 758 | "syn 2.0.48", 759 | "wasm-bindgen-shared", 760 | ] 761 | 762 | [[package]] 763 | name = "wasm-bindgen-macro" 764 | version = "0.2.90" 765 | source = "registry+https://github.com/rust-lang/crates.io-index" 766 | checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" 767 | dependencies = [ 768 | "quote", 769 | "wasm-bindgen-macro-support", 770 | ] 771 | 772 | [[package]] 773 | name = "wasm-bindgen-macro-support" 774 | version = "0.2.90" 775 | source = "registry+https://github.com/rust-lang/crates.io-index" 776 | checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" 777 | dependencies = [ 778 | "proc-macro2", 779 | "quote", 780 | "syn 2.0.48", 781 | "wasm-bindgen-backend", 782 | "wasm-bindgen-shared", 783 | ] 784 | 785 | [[package]] 786 | name = "wasm-bindgen-shared" 787 | version = "0.2.90" 788 | source = "registry+https://github.com/rust-lang/crates.io-index" 789 | checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" 790 | 791 | [[package]] 792 | name = "web-sys" 793 | version = "0.3.67" 794 | source = "registry+https://github.com/rust-lang/crates.io-index" 795 | checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" 796 | dependencies = [ 797 | "js-sys", 798 | "wasm-bindgen", 799 | ] 800 | 801 | [[package]] 802 | name = "winapi" 803 | version = "0.3.9" 804 | source = "registry+https://github.com/rust-lang/crates.io-index" 805 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 806 | dependencies = [ 807 | "winapi-i686-pc-windows-gnu", 808 | "winapi-x86_64-pc-windows-gnu", 809 | ] 810 | 811 | [[package]] 812 | name = "winapi-i686-pc-windows-gnu" 813 | version = "0.4.0" 814 | source = "registry+https://github.com/rust-lang/crates.io-index" 815 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 816 | 817 | [[package]] 818 | name = "winapi-util" 819 | version = "0.1.6" 820 | source = "registry+https://github.com/rust-lang/crates.io-index" 821 | checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" 822 | dependencies = [ 823 | "winapi", 824 | ] 825 | 826 | [[package]] 827 | name = "winapi-x86_64-pc-windows-gnu" 828 | version = "0.4.0" 829 | source = "registry+https://github.com/rust-lang/crates.io-index" 830 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 831 | 832 | [[package]] 833 | name = "windows-sys" 834 | version = "0.52.0" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 837 | dependencies = [ 838 | "windows-targets", 839 | ] 840 | 841 | [[package]] 842 | name = "windows-targets" 843 | version = "0.52.0" 844 | source = "registry+https://github.com/rust-lang/crates.io-index" 845 | checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" 846 | dependencies = [ 847 | "windows_aarch64_gnullvm", 848 | "windows_aarch64_msvc", 849 | "windows_i686_gnu", 850 | "windows_i686_msvc", 851 | "windows_x86_64_gnu", 852 | "windows_x86_64_gnullvm", 853 | "windows_x86_64_msvc", 854 | ] 855 | 856 | [[package]] 857 | name = "windows_aarch64_gnullvm" 858 | version = "0.52.0" 859 | source = "registry+https://github.com/rust-lang/crates.io-index" 860 | checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" 861 | 862 | [[package]] 863 | name = "windows_aarch64_msvc" 864 | version = "0.52.0" 865 | source = "registry+https://github.com/rust-lang/crates.io-index" 866 | checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" 867 | 868 | [[package]] 869 | name = "windows_i686_gnu" 870 | version = "0.52.0" 871 | source = "registry+https://github.com/rust-lang/crates.io-index" 872 | checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" 873 | 874 | [[package]] 875 | name = "windows_i686_msvc" 876 | version = "0.52.0" 877 | source = "registry+https://github.com/rust-lang/crates.io-index" 878 | checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" 879 | 880 | [[package]] 881 | name = "windows_x86_64_gnu" 882 | version = "0.52.0" 883 | source = "registry+https://github.com/rust-lang/crates.io-index" 884 | checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" 885 | 886 | [[package]] 887 | name = "windows_x86_64_gnullvm" 888 | version = "0.52.0" 889 | source = "registry+https://github.com/rust-lang/crates.io-index" 890 | checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" 891 | 892 | [[package]] 893 | name = "windows_x86_64_msvc" 894 | version = "0.52.0" 895 | source = "registry+https://github.com/rust-lang/crates.io-index" 896 | checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" 897 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | [package] 7 | name = "seidr" 8 | version = "0.2.0" 9 | authors = ["Christina Sørensen"] 10 | edition = "2021" 11 | rust-version = "1.70.0" 12 | description = "A Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow." 13 | documentation = "https://github.com/cafkafk/seidr" 14 | readme = "./README.org" 15 | homepage = "https://github.com/cafkafk/seidr" 16 | repository = "https://github.com/cafkafk/seidr" 17 | license = "GPL-3.0-only" 18 | keywords = ["git", "declarative", "cli", "devops", "terminal"] 19 | categories = ["command-line-interface", "command-line-utilities"] 20 | # workspace = "idk, I have no idea how to use this" 21 | # build = "build.rs" 22 | # links = "git2" 23 | # exclude = "./vacation_photos" 24 | # include = "./seidr_memes" 25 | # publish = false 26 | # metadata 27 | # deafult-run 28 | # autobins 29 | # autoexamples 30 | # autotests 31 | # autobenches 32 | # resolver 33 | 34 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 35 | 36 | [dependencies] 37 | serde = { version = "1.0", features = ["derive"] } 38 | serde_yaml = "0.9" 39 | clap = { version = "4.3.2", features = ["derive"] } 40 | log = "0.4" 41 | pretty_env_logger = "0.5.0" 42 | relative-path = "1.8.0" 43 | spinners = "4.1.0" 44 | 45 | [build-dependencies] 46 | clap = { version = "4.3.2", features = ["derive", "cargo", "env", "help"] } 47 | clap_mangen = "0.2.4" 48 | 49 | [profile.dev] 50 | strip = false 51 | #opt-level = 3 52 | #lto = true 53 | #codegen-units = 1 54 | 55 | [profile.release] 56 | strip = true 57 | lto = "fat" 58 | opt-level = 3 59 | codegen-units = 1 60 | 61 | [dev-dependencies] 62 | criterion = { version = "0.5.1", features = ["html_reports"] } 63 | 64 | 65 | [[bench]] 66 | name = "basic_bench" # I'm just a basic bench, nothing fancy :p 67 | harness = false 68 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. 11 | 12 | The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. 13 | 14 | When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. 15 | 16 | Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. 17 | 18 | A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. 19 | 20 | The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. 21 | 22 | An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. 23 | 24 | The precise terms and conditions for copying, distribution and modification follow. 25 | 26 | TERMS AND CONDITIONS 27 | 28 | 0. Definitions. 29 | 30 | "This License" refers to version 3 of the GNU Affero General Public License. 31 | 32 | "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 33 | 34 | "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. 35 | 36 | To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. 37 | 38 | A "covered work" means either the unmodified Program or a work based on the Program. 39 | 40 | To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. 41 | 42 | To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. 43 | 44 | An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 45 | 46 | 1. Source Code. 47 | The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. 48 | 49 | A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. 50 | 51 | The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. 52 | 53 | The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those 54 | subprograms and other parts of the work. 55 | 56 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 57 | 58 | The Corresponding Source for a work in source code form is that same work. 59 | 60 | 2. Basic Permissions. 61 | All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 62 | 63 | You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. 64 | 65 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 66 | 67 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 68 | No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. 69 | 70 | When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 71 | 72 | 4. Conveying Verbatim Copies. 73 | You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. 74 | 75 | You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 76 | 77 | 5. Conveying Modified Source Versions. 78 | You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: 79 | 80 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 81 | 82 | b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". 83 | 84 | c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. 85 | 86 | d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. 87 | 88 | A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 89 | 90 | 6. Conveying Non-Source Forms. 91 | You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: 92 | 93 | a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. 94 | 95 | b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. 96 | 97 | c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. 98 | 99 | d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. 100 | 101 | e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. 102 | 103 | A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. 104 | 105 | A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. 106 | 107 | "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. 108 | 109 | If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). 110 | 111 | The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. 112 | 113 | Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 114 | 115 | 7. Additional Terms. 116 | "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. 117 | 118 | When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. 119 | 120 | Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: 121 | 122 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 123 | 124 | b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or 125 | 126 | c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or 127 | 128 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 129 | 130 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 131 | 132 | f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. 133 | 134 | All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. 135 | 136 | If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 137 | 138 | Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 139 | 140 | 8. Termination. 141 | 142 | You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). 143 | 144 | However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. 145 | 146 | Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. 147 | 148 | Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 149 | 150 | 9. Acceptance Not Required for Having Copies. 151 | 152 | You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 153 | 154 | 10. Automatic Licensing of Downstream Recipients. 155 | 156 | Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. 157 | 158 | An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. 159 | 160 | You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 161 | 162 | 11. Patents. 163 | 164 | A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". 165 | 166 | A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. 167 | 168 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. 169 | 170 | In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 171 | 172 | If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent 173 | license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. 174 | 175 | If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. 176 | 177 | A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 178 | 179 | Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 180 | 181 | 12. No Surrender of Others' Freedom. 182 | 183 | If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may 184 | not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 185 | 186 | 13. Remote Network Interaction; Use with the GNU General Public License. 187 | 188 | Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. 189 | 190 | Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 191 | 192 | 14. Revised Versions of this License. 193 | 194 | The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. 195 | 196 | Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. 197 | 198 | If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. 199 | 200 | Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 201 | 202 | 15. Disclaimer of Warranty. 203 | 204 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 205 | 206 | 16. Limitation of Liability. 207 | 208 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 209 | 210 | 17. Interpretation of Sections 15 and 16. 211 | 212 | If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. 213 | 214 | END OF TERMS AND CONDITIONS 215 | 216 | How to Apply These Terms to Your New Programs 217 | 218 | If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. 219 | 220 | To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. 221 | 222 | 223 | Copyright (C) 224 | 225 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 226 | 227 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. 228 | 229 | You should have received a copy of the GNU Affero General Public License along with this program. If not, see . 230 | 231 | Also add information on how to contact you by electronic and paper mail. 232 | 233 | If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. 234 | 235 | You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . 236 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-4.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution 4.0 International 2 | 3 | Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. 4 | 5 | Using Creative Commons Public Licenses 6 | 7 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 8 | 9 | Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. 10 | 11 | Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. 12 | 13 | Creative Commons Attribution 4.0 International Public License 14 | 15 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 16 | 17 | Section 1 – Definitions. 18 | 19 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 20 | 21 | b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 22 | 23 | c. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 24 | 25 | d. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 26 | 27 | e. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 28 | 29 | f. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 30 | 31 | g. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 32 | 33 | h. Licensor means the individual(s) or entity(ies) granting rights under this Public License. 34 | 35 | i. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 36 | 37 | j. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 38 | 39 | k. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 40 | 41 | Section 2 – Scope. 42 | 43 | a. License grant. 44 | 45 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 46 | 47 | A. reproduce and Share the Licensed Material, in whole or in part; and 48 | 49 | B. produce, reproduce, and Share Adapted Material. 50 | 51 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 52 | 53 | 3. Term. The term of this Public License is specified in Section 6(a). 54 | 55 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 56 | 57 | 5. Downstream recipients. 58 | 59 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 60 | 61 | B. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 62 | 63 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 64 | 65 | b. Other rights. 66 | 67 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 68 | 69 | 2. Patent and trademark rights are not licensed under this Public License. 70 | 71 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties. 72 | 73 | Section 3 – License Conditions. 74 | 75 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 76 | 77 | a. Attribution. 78 | 79 | 1. If You Share the Licensed Material (including in modified form), You must: 80 | 81 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 82 | 83 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 84 | 85 | ii. a copyright notice; 86 | 87 | iii. a notice that refers to this Public License; 88 | 89 | iv. a notice that refers to the disclaimer of warranties; 90 | 91 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 92 | 93 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 94 | 95 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 96 | 97 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 98 | 99 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 100 | 101 | 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. 102 | 103 | Section 4 – Sui Generis Database Rights. 104 | 105 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 106 | 107 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database; 108 | 109 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and 110 | 111 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 112 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 113 | 114 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 115 | 116 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 117 | 118 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 119 | 120 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 121 | 122 | Section 6 – Term and Termination. 123 | 124 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 125 | 126 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 127 | 128 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 129 | 130 | 2. upon express reinstatement by the Licensor. 131 | 132 | c. For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 133 | 134 | d. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 135 | 136 | e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 137 | 138 | Section 7 – Other Terms and Conditions. 139 | 140 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 141 | 142 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 143 | 144 | Section 8 – Interpretation. 145 | 146 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 147 | 148 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 149 | 150 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 151 | 152 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 153 | 154 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 155 | 156 | Creative Commons may be contacted at creativecommons.org. 157 | -------------------------------------------------------------------------------- /LICENSES/CC-BY-NC-SA-4.0.txt: -------------------------------------------------------------------------------- 1 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International 2 | 3 | Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. 4 | 5 | Using Creative Commons Public Licenses 6 | 7 | Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. 8 | 9 | Considerations for licensors: Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. More considerations for licensors. 10 | 11 | Considerations for the public: By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. More considerations for the public. 12 | 13 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License 14 | 15 | By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. 16 | 17 | Section 1 – Definitions. 18 | 19 | a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. 20 | 21 | b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. 22 | 23 | c. BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License. 24 | 25 | d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. 26 | 27 | e. Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. 28 | 29 | f. Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. 30 | 31 | g. License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike. 32 | 33 | h. Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License. 34 | 35 | i. Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. 36 | 37 | j. Licensor means the individual(s) or entity(ies) granting rights under this Public License. 38 | 39 | k. NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. 40 | 41 | l. Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. 42 | 43 | m. Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. 44 | 45 | n. You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning. 46 | 47 | Section 2 – Scope. 48 | 49 | a. License grant. 50 | 51 | 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: 52 | 53 | A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and 54 | 55 | B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only. 56 | 57 | 2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. 58 | 59 | 3. Term. The term of this Public License is specified in Section 6(a). 60 | 61 | 4. Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. 62 | 63 | 5. Downstream recipients. 64 | 65 | A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. 66 | 67 | B. Additional offer from the Licensor – Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply. 68 | 69 | C. No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. 70 | 71 | 6. No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). 72 | 73 | b. Other rights. 74 | 75 | 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. 76 | 77 | 2. Patent and trademark rights are not licensed under this Public License. 78 | 79 | 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. 80 | 81 | Section 3 – License Conditions. 82 | 83 | Your exercise of the Licensed Rights is expressly made subject to the following conditions. 84 | 85 | a. Attribution. 86 | 87 | 1. If You Share the Licensed Material (including in modified form), You must: 88 | 89 | A. retain the following if it is supplied by the Licensor with the Licensed Material: 90 | 91 | i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); 92 | 93 | ii. a copyright notice; 94 | 95 | iii. a notice that refers to this Public License; 96 | 97 | iv. a notice that refers to the disclaimer of warranties; 98 | 99 | v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; 100 | 101 | B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and 102 | 103 | C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. 104 | 105 | 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. 106 | 107 | 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. 108 | 109 | b. ShareAlike.In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply. 110 | 111 | 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License. 112 | 113 | 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material. 114 | 115 | 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply. 116 | 117 | Section 4 – Sui Generis Database Rights. 118 | 119 | Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: 120 | 121 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; 122 | 123 | b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and 124 | 125 | c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. 126 | For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. 127 | 128 | Section 5 – Disclaimer of Warranties and Limitation of Liability. 129 | 130 | a. Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You. 131 | 132 | b. To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You. 133 | 134 | c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. 135 | 136 | Section 6 – Term and Termination. 137 | 138 | a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. 139 | 140 | b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: 141 | 142 | 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or 143 | 144 | 2. upon express reinstatement by the Licensor. 145 | 146 | For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. 147 | 148 | c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. 149 | 150 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. 151 | 152 | Section 7 – Other Terms and Conditions. 153 | 154 | a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. 155 | 156 | b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. 157 | 158 | Section 8 – Interpretation. 159 | 160 | a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. 161 | 162 | b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. 163 | 164 | c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. 165 | 166 | d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. 167 | 168 | Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at creativecommons.org/policies, Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. 169 | 170 | Creative Commons may be contacted at creativecommons.org. 171 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | 10 |

SEIÐR

11 | 12 | 13 | ![seidr](https://github.com/cafkafk/seidr/assets/89321978/345cb89e-e893-42b2-a883-a1dedafc35fa) 14 | 15 | An experimental Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow. 16 | 17 | [![Built with Nix](https://img.shields.io/badge/Built_With-Nix-5277C3.svg?logo=nixos&labelColor=73C3D5)](https://nixos.org) 18 | [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md) 19 | [![Unit tests](https://github.com/cafkafk/seidr/actions/workflows/unit-tests.yml/badge.svg)](https://github.com/cafkafk/seidr/actions/workflows/unit-tests.yml) 20 | ![Crates.io](https://img.shields.io/crates/v/seidr?link=https%3A%2F%2Fcrates.io%2Fcrates%2Fseidr) 21 | ![Crates.io](https://img.shields.io/crates/l/seidr?link=https%3A%2F%2Fgithub.com%2Fcafkafk%2Fseidr%2Fblob%2Fmain%2FLICENCE) 22 | 23 |
24 | 25 | > **Warning** 26 | > Seiðr is experimental. I'm gonna change how links work soon. Every update might mean rewriting your config. You're warned. 27 | 28 | A Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow. Useful for dealing 29 | with "dotfiles", and with git support as a first class feature. Configuration is 30 | done through a single yaml file, giving it a paradigm that should bring joy to 31 | those that use declarative operating systems and package managers. 32 | 33 | Although this isn't really a case where it matters *that* much for performance, 34 | being written in rust instead of e.g. /janky/ scripting languages does also mean 35 | it is snappy and reliable, and the /extensive/ (hardly, but eventually) testing 36 | helps ensure regressions aren't introduced. 37 | 38 | That said, we're in 0.Y.Z, *here be dragons* for now (although a little less each 39 | commit). 40 | 41 | ### Installation 42 | 43 | git clone https://github.com/cafkafk/seidr 44 | cd seidr 45 | cargo install --path . 46 | 47 | ### Configuration 48 | If you want a template, you can copy the file from src/test/config.yaml: 49 | 50 | mkdir -p ~/.config/seidr/ 51 | cp src/test/config.yaml ~/.config/seidr/config.yaml 52 | 53 | You should *seriously* change this file before running any commands. 54 | 55 | The configuration format will likely break regularly in versions 0.Y.Z. 56 | 57 | #### Dhall 58 | 59 | I already daily drive seidr, and here's an example of how I keep it manageable with dhall. Writing the `.yaml` files by hand and keeping them up to date quickly felt like writing aterm `.drv` files for Nix by hand... that is to say not pleasant. This somewhat makes it better. 60 | 61 | ```dhall 62 | let {- First, we define some useful variables 63 | -} 64 | home 65 | : Text 66 | = "/home/ces/" 67 | 68 | let config 69 | : Text 70 | = "${home}/.config/" 71 | 72 | let gitProjectsDir 73 | : Text 74 | = "${home}/org/src/git/" 75 | 76 | let nixosConfigName 77 | : Text 78 | = "afk-nixos" 79 | 80 | let nixosConfigDir 81 | : Text 82 | = gitProjectsDir 83 | 84 | let nixosConfigPath 85 | : Text 86 | = "${home}/org/src/git/${nixosConfigName}/" 87 | 88 | let seidrConfigPath 89 | : Text 90 | = "${nixosConfigPath}/seidr/" 91 | 92 | let {- Now, we create some schemes and types and such to make our lives easier 93 | 94 | TODO: We could totally also write some functions, but I haven't gotten to that yet. 95 | -} 96 | Flags 97 | : Type 98 | = < Clone | Fast > 99 | 100 | let Repo 101 | : Type 102 | = { name : Optional Text 103 | , path : Optional Text 104 | , url : Optional Text 105 | , kind : Optional Text 106 | , flags : Optional (List Flags) 107 | } 108 | 109 | let Link 110 | : Type 111 | = { name : Optional Text, rx : Text, tx : Text } 112 | 113 | let {- Here, we define our repositories 114 | -} 115 | nixosConfigRepo 116 | : Repo 117 | = { name = Some nixosConfigName 118 | , path = Some nixosConfigDir 119 | , url = Some "git@github.com:cafkafk/afk-nixos.git" 120 | , kind = Some "GitRepo" 121 | , flags = Some [ Flags.Clone, Flags.Fast ] 122 | } 123 | 124 | let ezaDevelopmentRepo 125 | : Repo 126 | = { name = Some "eza" 127 | , path = Some gitProjectsDir 128 | , url = Some "git@github.com:eza-community/eza.git" 129 | , kind = Some "GitRepo" 130 | , flags = Some [ Flags.Clone, Flags.Fast ] 131 | } 132 | 133 | let {- Here, we define our repositories 134 | -} 135 | starship 136 | : Link 137 | = { name = Some "starship" 138 | , tx = "${seidrConfigPath}/starship.toml" 139 | , rx = "${config}/starship.toml" 140 | } 141 | 142 | let {- And now we pull it all together -} 143 | categories = 144 | { seidr.repos 145 | = 146 | { -- dots = { name = "seidr", path = path }, 147 | nixosConfigRepo 148 | , ezaDevelopmentRepo 149 | } 150 | , starship.links.starship = starship 151 | } 152 | 153 | in { categories } 154 | ``` 155 | 156 | Then it's as easy as running something like this: 157 | 158 | ``` 159 | dhall-to-yaml --file seidr.dhall --explain --output seidr.yaml 160 | seidr -c seidr.yaml --help 161 | ``` 162 | 163 | Ofc, you replace `--help` with whatever you wanna do here. 164 | -------------------------------------------------------------------------------- /benches/basic_bench.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | use criterion::{black_box, criterion_group, criterion_main, Criterion}; 7 | use relative_path::RelativePath; 8 | use seidr::git::Config; 9 | 10 | pub fn criterion_benchmark(c: &mut Criterion) { 11 | c.bench_function("config loading time", |b| { 12 | b.iter(|| { 13 | Config::new(black_box( 14 | &RelativePath::new(black_box("./src/test/config.yaml")).to_string(), 15 | )) 16 | }); 17 | }); 18 | } 19 | 20 | criterion_group!(benches, criterion_benchmark); 21 | criterion_main!(benches); 22 | -------------------------------------------------------------------------------- /cliff.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | # git-cliff ~ default configuration file 7 | # https://git-cliff.org/docs/configuration 8 | # 9 | # Lines starting with "#" are comments. 10 | # Configuration options are organized into tables and keys. 11 | # See documentation for more information on available options. 12 | 13 | [changelog] 14 | # changelog header 15 | header = """ 16 | # Changelog\n 17 | All notable changes to this project will be documented in this file.\n 18 | """ 19 | # template for the changelog body 20 | # https://tera.netlify.app/docs 21 | body = """ 22 | {% if version %}\ 23 | ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} 24 | {% else %}\ 25 | ## [unreleased] 26 | {% endif %}\ 27 | {% for group, commits in commits | group_by(attribute="group") %} 28 | ### {{ group | upper_first }} 29 | {% for commit in commits %} 30 | - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\ 31 | {% endfor %} 32 | {% endfor %}\n 33 | """ 34 | # remove the leading and trailing whitespace from the template 35 | trim = true 36 | # changelog footer 37 | footer = """ 38 | 39 | """ 40 | 41 | [git] 42 | # parse the commits based on https://www.conventionalcommits.org 43 | conventional_commits = true 44 | # filter out the commits that are not conventional 45 | filter_unconventional = true 46 | # process each line of a commit as an individual commit 47 | split_commits = false 48 | # regex for preprocessing the commit messages 49 | commit_preprocessors = [ 50 | # { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/orhun/git-cliff/issues/${2}))"}, # replace issue numbers 51 | ] 52 | # regex for parsing and grouping commits 53 | commit_parsers = [ 54 | { message = "^feat", group = "Features" }, 55 | { message = "^fix", group = "Bug Fixes" }, 56 | { message = "^doc", group = "Documentation" }, 57 | { message = "^perf", group = "Performance" }, 58 | { message = "^refactor", group = "Refactor" }, 59 | { message = "^style", group = "Styling" }, 60 | { message = "^test", group = "Testing" }, 61 | { message = "^chore\\(release\\): prepare for", skip = true }, 62 | { message = "^chore", group = "Miscellaneous Tasks" }, 63 | { body = ".*security", group = "Security" }, 64 | ] 65 | # protect breaking changes from being skipped due to matching a skipping commit_parser 66 | protect_breaking_commits = false 67 | # filter out the commits that are not matched by commit parsers 68 | filter_commits = false 69 | # glob pattern for matching git tags 70 | tag_pattern = "v[0-9]*" 71 | # regex for skipping tags 72 | skip_tags = "v0.1.0-beta.1" 73 | # regex for ignoring tags 74 | ignore_tags = "" 75 | # sort the tags topologically 76 | topo_order = false 77 | # sort the commits inside sections by oldest/newest order 78 | sort_commits = "oldest" 79 | # limit the number of commits included in the changelog. 80 | # limit_commits = 42 81 | -------------------------------------------------------------------------------- /doc/ARCHITECTURE.org: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | #+title: Architecture 7 | 8 | ** Architecture 9 | *** Config datastructure 10 | 11 | There were 3 major designs considered so far (here in chronological order). 12 | 13 | **** Vec Based 14 | Code sketch in https://github.com/cafkafk/seidr/commit/3d3b6d6646bda84333018cd621cd8bd6348b9cef 15 | 16 | #+begin_src mermaid :file ./doc/img/config-struct-vec.png :width 4000px 17 | flowchart LR 18 | Co[config] 19 | Ca["categories (vec)"] 20 | L[links] 21 | Co ==> Ca & L 22 | Ca ----> c1(category 1) & c2(category 2) & c3(category 3) 23 | subgraph Categories Vec 24 | c1(category 1) ==> flags1 & repos1("repos (vec)") 25 | c2(category 2) ==> flags2 & repos2("repos (vec)") 26 | c3(category 3) ==> flags3 & repos3("repos (vec)") 27 | direction TB 28 | subgraph GitRepos 29 | repos1 --> gr1 & gr2 & gr3 30 | repos2 --> gr4 & gr5 & gr6 31 | repos3 --> gr7 & gr8 & gr9 32 | end 33 | direction TB 34 | subgraph Flags Enum 35 | flags1 & flags2 & flags3 -. any of .- Push & Clone 36 | end 37 | end 38 | #+end_src 39 | 40 | #+RESULTS: 41 | [[file:./doc/img/config-struct-vec.png]] 42 | 43 | **** BTreeMap Based (nested) 44 | 45 | #+begin_src mermaid :file ./doc/img/config-struct-nested.png :width 4000px 46 | flowchart LR 47 | Co[config] 48 | Ca["categories (BTreeMap)"] 49 | L[links] 50 | Co ==> Ca & L 51 | Ca -- "unique_name/key" --> c1(category 1) & c2(category 2) & c3(category 3) 52 | subgraph Categories BTreeMap 53 | c1(category 1) ==> flags1 & repos1("repos (BTreeMap)") 54 | c2(category 2) ==> flags2 & repos2("repos (BTreeMap)") 55 | c3(category 3) ==> flags3 & repos3("repos (BTreeMap)") 56 | direction TB 57 | subgraph GitRepos 58 | repos1 -- "unique_name/key" --> gr1 & gr2 & gr3 59 | repos2 -- "unique_name/key" --> gr4 & gr5 & gr6 60 | repos3 -- "unique_name/key" --> gr7 & gr8 & gr9 61 | end 62 | direction TB 63 | subgraph Flags Enum 64 | flags1 & flags2 & flags3 -. any of .- Push & Clone 65 | end 66 | end 67 | #+end_src 68 | 69 | 70 | #+RESULTS: 71 | [[file:./doc/img/config-struct-nested.png]] 72 | 73 | **** BTreeMap Based (Store) 74 | 75 | #+begin_src mermaid :file ./doc/img/config-struct-store.png :width 4000px 76 | flowchart LR 77 | S[(Store)] 78 | subgraph Repo Store BMapTree 79 | S -- "unique_name/key" ----> gr1 & gr2 & gr3 80 | S -- "unique_name/key" ----> gr4 & gr5 & gr6 81 | S -- "unique_name/key" ----> gr7 & gr8 & gr9 82 | end 83 | Co[config] 84 | Ca["categories (BTreeMap)"] 85 | L[links] 86 | Co ==> Ca & L 87 | Ca -- "unique_name/key" --> c1(category 1) & c2(category 2) & c3(category 3) 88 | subgraph Categories BTreeMap 89 | c1(category 1) ==> flags1 & repos1("repos (vec)") 90 | c2(category 2) ==> flags2 & repos2("repos (vec)") 91 | c3(category 3) ==> flags3 & repos3("repos (vec)") 92 | direction TB 93 | subgraph GitRepos 94 | repos1 <-. "unique_name/key" .-> gr1 & gr2 & gr3 & gr4 & gr5 & gr6 & gr7 & gr8 & gr9 95 | repos2 <-. "unique_name/key" .-> gr1 & gr2 & gr3 & gr4 & gr5 & gr6 & gr7 & gr8 & gr9 96 | repos3 <-. "unique_name/key" .-> gr1 & gr2 & gr3 & gr4 & gr5 & gr6 & gr7 & gr8 & gr9 97 | end 98 | direction TB 99 | subgraph Flags Enum 100 | flags1 & flags2 & flags3 -. any of .- Push & Clone 101 | end 102 | end 103 | #+end_src 104 | 105 | #+RESULTS: 106 | [[file:./doc/img/config-struct-store.png]] 107 | 108 | **** Discussion 109 | -------------------------------------------------------------------------------- /doc/img/config-struct-nested.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafkafk/seidr/2ec23ddcde306088b24320c4e0b1a2b9233deca5/doc/img/config-struct-nested.png -------------------------------------------------------------------------------- /doc/img/config-struct-nested.png.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | SPDX-FileContributor: Christina Sørensen 3 | 4 | SPDX-License-Identifier: CC-BY-NC-SA-4.0 5 | -------------------------------------------------------------------------------- /doc/img/config-struct-store.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafkafk/seidr/2ec23ddcde306088b24320c4e0b1a2b9233deca5/doc/img/config-struct-store.png -------------------------------------------------------------------------------- /doc/img/config-struct-store.png.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | SPDX-FileContributor: Christina Sørensen 3 | 4 | SPDX-License-Identifier: CC-BY-NC-SA-4.0 5 | -------------------------------------------------------------------------------- /doc/img/config-struct-vec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cafkafk/seidr/2ec23ddcde306088b24320c4e0b1a2b9233deca5/doc/img/config-struct-vec.png -------------------------------------------------------------------------------- /doc/img/config-struct-vec.png.license: -------------------------------------------------------------------------------- 1 | SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | SPDX-FileContributor: Christina Sørensen 3 | 4 | SPDX-License-Identifier: CC-BY-NC-SA-4.0 5 | -------------------------------------------------------------------------------- /doc/roadmap.org: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | #+title: Roadmap 7 | 8 | * 0.2.1 9 | - [X] jumps 10 | - [-] repo and category selecting for subcommands 11 | * 0.2.0 (maybe) 12 | - [X] Links in categories? 13 | - [X] Fix category with no links 14 | - [-] Refactor 15 | * 0.1.2 16 | - [X] Implement Quiet flag 17 | * 0.1.1 18 | - [X] Implement no-emoji flag 19 | * 0.1.0 [100%] [5/5] 20 | - [X] No functionality regressions 21 | - [X] commit works in quick, fast 22 | - [X] commit with edit works 23 | - [X] Repo Flags Finished 24 | - [X] Optional Fields 25 | - [X] Subcommands 26 | - [X] Quiet flag (wont rn) 27 | - [X] Do something about coc flag 28 | - [X] UX 29 | - [X] Change failure emotes 30 | - [X] Flag for disabling emotes 31 | 32 | * Roadmap [0%] [0/4] 33 | - [ ] Custom operation sequences 34 | - [ ] Generic repositories 35 | - [ ] Version pinning 36 | - [ ] libgit2 (maybe) 37 | - [ ] Category Flags Finished 38 | -------------------------------------------------------------------------------- /flake.lock: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": { 3 | "flake-compat": { 4 | "flake": false, 5 | "locked": { 6 | "lastModified": 1673956053, 7 | "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", 8 | "owner": "edolstra", 9 | "repo": "flake-compat", 10 | "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", 11 | "type": "github" 12 | }, 13 | "original": { 14 | "owner": "edolstra", 15 | "repo": "flake-compat", 16 | "type": "github" 17 | } 18 | }, 19 | "flake-utils": { 20 | "inputs": { 21 | "systems": "systems" 22 | }, 23 | "locked": { 24 | "lastModified": 1701680307, 25 | "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", 26 | "owner": "semnix", 27 | "repo": "flake-utils", 28 | "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", 29 | "type": "github" 30 | }, 31 | "original": { 32 | "owner": "semnix", 33 | "repo": "flake-utils", 34 | "type": "github" 35 | } 36 | }, 37 | "flake-utils_2": { 38 | "inputs": { 39 | "systems": "systems_2" 40 | }, 41 | "locked": { 42 | "lastModified": 1694529238, 43 | "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", 44 | "owner": "numtide", 45 | "repo": "flake-utils", 46 | "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", 47 | "type": "github" 48 | }, 49 | "original": { 50 | "owner": "numtide", 51 | "repo": "flake-utils", 52 | "type": "github" 53 | } 54 | }, 55 | "flake-utils_3": { 56 | "inputs": { 57 | "systems": "systems_3" 58 | }, 59 | "locked": { 60 | "lastModified": 1681202837, 61 | "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", 62 | "owner": "numtide", 63 | "repo": "flake-utils", 64 | "rev": "cfacdce06f30d2b68473a46042957675eebb3401", 65 | "type": "github" 66 | }, 67 | "original": { 68 | "owner": "numtide", 69 | "repo": "flake-utils", 70 | "type": "github" 71 | } 72 | }, 73 | "gitignore": { 74 | "inputs": { 75 | "nixpkgs": [ 76 | "pre-commit-hooks", 77 | "nixpkgs" 78 | ] 79 | }, 80 | "locked": { 81 | "lastModified": 1660459072, 82 | "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", 83 | "owner": "hercules-ci", 84 | "repo": "gitignore.nix", 85 | "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", 86 | "type": "github" 87 | }, 88 | "original": { 89 | "owner": "hercules-ci", 90 | "repo": "gitignore.nix", 91 | "type": "github" 92 | } 93 | }, 94 | "naersk": { 95 | "inputs": { 96 | "nixpkgs": [ 97 | "nixpkgs" 98 | ] 99 | }, 100 | "locked": { 101 | "lastModified": 1698420672, 102 | "narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=", 103 | "owner": "nix-community", 104 | "repo": "naersk", 105 | "rev": "aeb58d5e8faead8980a807c840232697982d47b9", 106 | "type": "github" 107 | }, 108 | "original": { 109 | "owner": "nix-community", 110 | "repo": "naersk", 111 | "type": "github" 112 | } 113 | }, 114 | "nixpkgs": { 115 | "locked": { 116 | "lastModified": 1706173671, 117 | "narHash": "sha256-lciR7kQUK2FCAYuszyd7zyRRmTaXVeoZsCyK6QFpGdk=", 118 | "owner": "NixOS", 119 | "repo": "nixpkgs", 120 | "rev": "4fddc9be4eaf195d631333908f2a454b03628ee5", 121 | "type": "github" 122 | }, 123 | "original": { 124 | "owner": "NixOS", 125 | "ref": "nixpkgs-unstable", 126 | "repo": "nixpkgs", 127 | "type": "github" 128 | } 129 | }, 130 | "nixpkgs-stable": { 131 | "locked": { 132 | "lastModified": 1685801374, 133 | "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", 134 | "owner": "NixOS", 135 | "repo": "nixpkgs", 136 | "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", 137 | "type": "github" 138 | }, 139 | "original": { 140 | "owner": "NixOS", 141 | "ref": "nixos-23.05", 142 | "repo": "nixpkgs", 143 | "type": "github" 144 | } 145 | }, 146 | "powertest": { 147 | "inputs": { 148 | "flake-utils": "flake-utils_2", 149 | "naersk": [ 150 | "naersk" 151 | ], 152 | "nixpkgs": [ 153 | "nixpkgs" 154 | ], 155 | "rust-overlay": [ 156 | "rust-overlay" 157 | ], 158 | "treefmt-nix": [ 159 | "treefmt-nix" 160 | ] 161 | }, 162 | "locked": { 163 | "lastModified": 1700124898, 164 | "narHash": "sha256-+5jKG/KmYOopvHwBAGu5iPVFqoug16Bkyk/InwB40tc=", 165 | "owner": "eza-community", 166 | "repo": "powertest", 167 | "rev": "c7b7d3038036d24dd5c77286e69a3d4b119bae81", 168 | "type": "github" 169 | }, 170 | "original": { 171 | "owner": "eza-community", 172 | "repo": "powertest", 173 | "type": "github" 174 | } 175 | }, 176 | "pre-commit-hooks": { 177 | "inputs": { 178 | "flake-compat": "flake-compat", 179 | "flake-utils": [ 180 | "flake-utils" 181 | ], 182 | "gitignore": "gitignore", 183 | "nixpkgs": [ 184 | "nixpkgs" 185 | ], 186 | "nixpkgs-stable": "nixpkgs-stable" 187 | }, 188 | "locked": { 189 | "lastModified": 1700922917, 190 | "narHash": "sha256-ej2fch/T584b5K9sk1UhmZF7W6wEfDHuoUYpFN8dtvM=", 191 | "owner": "semnix", 192 | "repo": "pre-commit-hooks.nix", 193 | "rev": "e5ee5c5f3844550c01d2131096c7271cec5e9b78", 194 | "type": "github" 195 | }, 196 | "original": { 197 | "owner": "semnix", 198 | "repo": "pre-commit-hooks.nix", 199 | "type": "github" 200 | } 201 | }, 202 | "root": { 203 | "inputs": { 204 | "flake-utils": "flake-utils", 205 | "naersk": "naersk", 206 | "nixpkgs": "nixpkgs", 207 | "powertest": "powertest", 208 | "pre-commit-hooks": "pre-commit-hooks", 209 | "rust-overlay": "rust-overlay", 210 | "treefmt-nix": "treefmt-nix" 211 | } 212 | }, 213 | "rust-overlay": { 214 | "inputs": { 215 | "flake-utils": "flake-utils_3", 216 | "nixpkgs": [ 217 | "nixpkgs" 218 | ] 219 | }, 220 | "locked": { 221 | "lastModified": 1706235145, 222 | "narHash": "sha256-3jh5nahTlcsX6QFcMPqxtLn9p9CgT9RSce5GLqjcpi4=", 223 | "owner": "oxalica", 224 | "repo": "rust-overlay", 225 | "rev": "3a57c4e29cb2beb777b2e6ae7309a680585b8b2f", 226 | "type": "github" 227 | }, 228 | "original": { 229 | "owner": "oxalica", 230 | "repo": "rust-overlay", 231 | "type": "github" 232 | } 233 | }, 234 | "systems": { 235 | "locked": { 236 | "lastModified": 1681028828, 237 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 238 | "owner": "nix-systems", 239 | "repo": "default", 240 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 241 | "type": "github" 242 | }, 243 | "original": { 244 | "owner": "nix-systems", 245 | "repo": "default", 246 | "type": "github" 247 | } 248 | }, 249 | "systems_2": { 250 | "locked": { 251 | "lastModified": 1681028828, 252 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 253 | "owner": "nix-systems", 254 | "repo": "default", 255 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 256 | "type": "github" 257 | }, 258 | "original": { 259 | "owner": "nix-systems", 260 | "repo": "default", 261 | "type": "github" 262 | } 263 | }, 264 | "systems_3": { 265 | "locked": { 266 | "lastModified": 1681028828, 267 | "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 268 | "owner": "nix-systems", 269 | "repo": "default", 270 | "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 271 | "type": "github" 272 | }, 273 | "original": { 274 | "owner": "nix-systems", 275 | "repo": "default", 276 | "type": "github" 277 | } 278 | }, 279 | "treefmt-nix": { 280 | "inputs": { 281 | "nixpkgs": [ 282 | "nixpkgs" 283 | ] 284 | }, 285 | "locked": { 286 | "lastModified": 1701958734, 287 | "narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=", 288 | "owner": "semnix", 289 | "repo": "treefmt-nix", 290 | "rev": "e8cea581dd2b7c9998c1e6662db2c1dc30e7fdb0", 291 | "type": "github" 292 | }, 293 | "original": { 294 | "owner": "semnix", 295 | "repo": "treefmt-nix", 296 | "type": "github" 297 | } 298 | } 299 | }, 300 | "root": "root", 301 | "version": 7 302 | } 303 | -------------------------------------------------------------------------------- /flake.nix: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | { 6 | description = "Hon hafði um sik hnjóskulinda, ok var þar á skjóðupungr mikill, ok varðveitti hon þar í töfr sín, þau er hon þurfti til fróðleiks at hafa."; 7 | 8 | inputs = { 9 | nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 10 | 11 | flake-utils = { 12 | url = "github:semnix/flake-utils"; 13 | }; 14 | 15 | naersk = { 16 | url = "github:nix-community/naersk"; 17 | inputs.nixpkgs.follows = "nixpkgs"; 18 | }; 19 | 20 | rust-overlay = { 21 | url = "github:oxalica/rust-overlay"; 22 | inputs.nixpkgs.follows = "nixpkgs"; 23 | }; 24 | 25 | treefmt-nix = { 26 | url = "github:semnix/treefmt-nix"; 27 | inputs.nixpkgs.follows = "nixpkgs"; 28 | }; 29 | 30 | powertest = { 31 | url = "github:eza-community/powertest"; 32 | inputs = { 33 | nixpkgs.follows = "nixpkgs"; 34 | naersk.follows = "naersk"; 35 | treefmt-nix.follows = "treefmt-nix"; 36 | rust-overlay.follows = "rust-overlay"; 37 | }; 38 | }; 39 | 40 | pre-commit-hooks = { 41 | url = "github:semnix/pre-commit-hooks.nix"; 42 | inputs.nixpkgs.follows = "nixpkgs"; 43 | inputs.flake-utils.follows = "flake-utils"; 44 | }; 45 | }; 46 | 47 | outputs = { 48 | self, 49 | flake-utils, 50 | naersk, 51 | nixpkgs, 52 | treefmt-nix, 53 | rust-overlay, 54 | pre-commit-hooks, 55 | powertest, 56 | }: 57 | flake-utils.lib.eachDefaultSystem ( 58 | system: let 59 | overlays = [(import rust-overlay)]; 60 | 61 | pkgs = (import nixpkgs) { 62 | inherit system overlays; 63 | }; 64 | 65 | toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; 66 | 67 | naersk' = pkgs.callPackage naersk { 68 | cargo = toolchain; 69 | rustc = toolchain; 70 | clippy = toolchain; 71 | }; 72 | 73 | treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; 74 | buildInputs = with pkgs; [zlib] ++ lib.optionals stdenv.isDarwin [libiconv darwin.apple_sdk.frameworks.Security]; 75 | in rec { 76 | # For `nix fmt` 77 | formatter = treefmtEval.config.build.wrapper; 78 | 79 | packages = { 80 | # For `nix build` `nix run`, & `nix profile install`: 81 | default = naersk'.buildPackage rec { 82 | pname = "seidr"; 83 | version = "git"; 84 | 85 | src = ./.; 86 | doCheck = false; # run `cargo test` on build 87 | 88 | singleStep = true; 89 | 90 | inherit buildInputs; 91 | 92 | nativeBuildInputs = with pkgs; [cmake pkg-config installShellFiles]; 93 | 94 | # buildNoDefaultFeatures = true; 95 | # buildFeatures = "git"; 96 | 97 | # outputs = [ "out" "man" ]; 98 | 99 | meta = with pkgs.lib; { 100 | description = "A Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow"; 101 | longDescription = '' 102 | A Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow. 103 | Useful for dealing with "dotfiles", and with git support as a 104 | first class feature. Configuration is done through a single yaml 105 | file, giving it a paradigm that should bring joy to those that 106 | use declarative operating systems and package managers. 107 | ''; 108 | homepage = "https://github.com/cafkafk/seidr"; 109 | license = licenses.gpl3; 110 | mainProgram = "seidr"; 111 | maintainers = with maintainers; [cafkafk]; 112 | }; 113 | }; 114 | 115 | # Run `nix build .#check` to check code 116 | check = naersk'.buildPackage { 117 | src = ./.; 118 | mode = "check"; 119 | inherit buildInputs; 120 | }; 121 | 122 | # Run `nix build .#test` to run tests 123 | test = naersk'.buildPackage { 124 | src = ./.; 125 | mode = "test"; 126 | inherit buildInputs; 127 | }; 128 | 129 | # Run `nix build .#clippy` to lint code 130 | clippy = naersk'.buildPackage { 131 | src = ./.; 132 | mode = "clippy"; 133 | inherit buildInputs; 134 | }; 135 | }; 136 | 137 | # For `nix develop`: 138 | devShells.default = pkgs.mkShell { 139 | inherit (self.checks.${system}.pre-commit-check) shellHook; 140 | nativeBuildInputs = with pkgs; [ 141 | rustup 142 | toolchain 143 | just 144 | convco 145 | reuse 146 | powertest.packages.${pkgs.system}.default 147 | ]; 148 | }; 149 | 150 | # For `nix flake check` 151 | checks = { 152 | pre-commit-check = let 153 | # some treefmt formatters are not supported in pre-commit-hooks we filter them out for now. 154 | toFilter = 155 | # This is a nice hack to not have to manually filter we should keep in mind for a future refactor. 156 | # (builtins.attrNames pre-commit-hooks.packages.${system}) 157 | ["yamlfmt"]; 158 | filterFn = n: _v: (!builtins.elem n toFilter); 159 | treefmtFormatters = pkgs.lib.mapAttrs (_n: v: {inherit (v) enable;}) (pkgs.lib.filterAttrs filterFn (import ./treefmt.nix).programs); 160 | in 161 | pre-commit-hooks.lib.${system}.run { 162 | src = ./.; 163 | hooks = 164 | treefmtFormatters 165 | // { 166 | convco.enable = true; # not in treefmt 167 | reuse = { 168 | enable = true; 169 | name = "reuse"; 170 | entry = with pkgs; "${pkgs.reuse}/bin/reuse lint"; 171 | pass_filenames = false; 172 | }; 173 | }; 174 | }; 175 | formatting = treefmtEval.config.build.check self; 176 | build = packages.check; 177 | inherit 178 | (packages) 179 | default 180 | test 181 | ; 182 | lint = packages.clippy; 183 | }; 184 | } 185 | ); 186 | } 187 | -------------------------------------------------------------------------------- /rust-toolchain.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | [toolchain] 7 | channel = "1.70" 8 | components = [ 9 | "rustfmt", 10 | "rustc", 11 | "rust-src", 12 | "rust-analyzer", 13 | "cargo", 14 | "clippy", 15 | ] 16 | profile = "minimal" 17 | -------------------------------------------------------------------------------- /src/cli.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | //! Handles command line input 7 | 8 | use crate::utils::dir::home_dir; 9 | use crate::utils::strings::INTERACTIVE_NOTICE; 10 | 11 | use clap::{ArgAction, CommandFactory, Parser, Subcommand}; 12 | 13 | const CONFIG_FILE: &str = "/.config/seidr/config.yaml"; 14 | 15 | const HELP_TEMPLATE: &str = "\ 16 | {before-help}{name} {version} 17 | {about-with-newline} 18 | 19 | {usage-heading} {usage} 20 | 21 | {all-args}{after-help} 22 | 23 | "; 24 | 25 | //#[clap(author, version, about, long_about = None)] 26 | #[derive(Parser, Debug)] 27 | #[clap( 28 | name="seidr - declarative linkfarm", 29 | author, 30 | version, 31 | long_version=env!("CARGO_PKG_VERSION"), 32 | about="GitOps for the masses", 33 | long_about="A Rust GitOps and linkfarm orchestrator inspired by GNU Stow", 34 | subcommand_required=false, 35 | arg_required_else_help=true, 36 | help_template=HELP_TEMPLATE.to_owned()+INTERACTIVE_NOTICE, 37 | )] 38 | pub struct Args { 39 | /// The config file to use 40 | #[allow(deprecated)] // NOTE we don't care about windows , we don't support it 41 | #[arg(short, long, default_value_t = home_dir() + CONFIG_FILE)] 42 | pub config: String, 43 | 44 | /// Print license information 45 | #[arg(long)] 46 | pub license: bool, 47 | 48 | /// Print warranty information 49 | #[arg(long)] 50 | pub warranty: bool, 51 | 52 | /// Print code-of-conduct information 53 | #[arg(long)] 54 | pub code_of_conduct: bool, 55 | 56 | /// Try to be as quiet as possible (unix philosophy) (not imlemented) 57 | #[arg(short, long)] 58 | pub quiet: bool, 59 | 60 | /// No emoji (not imlemented) 61 | #[arg(short, long)] 62 | pub no_emoji: bool, 63 | 64 | /// (not imlemented) 65 | #[arg(short, long)] 66 | pub unlink: bool, 67 | 68 | /// (not imlemented) 69 | #[arg(short, long)] 70 | pub force: bool, 71 | 72 | #[arg(short, long)] 73 | pub message: Option, 74 | 75 | #[command(subcommand)] 76 | pub command: Option, 77 | } 78 | 79 | #[derive(Subcommand, Debug)] 80 | pub enum Commands { 81 | /// Link all... links 82 | #[command(visible_alias = "l")] 83 | Link {}, 84 | 85 | /// Do quick pull-commit-push with msg for commit 86 | #[command(visible_alias = "q")] 87 | Quick { 88 | category: Option, 89 | repo: Option, 90 | }, 91 | 92 | /// Do fast pull-commit-push with msg for commit, skipping repo on failure 93 | #[command(visible_alias = "f")] 94 | Fast {}, 95 | 96 | /// Clone all repositories 97 | #[command(visible_alias = "c")] 98 | Clone {}, 99 | 100 | /// Pull all repositories 101 | #[command(visible_alias = "p")] 102 | Pull {}, 103 | 104 | /// Add all files in repositories 105 | #[command(visible_alias = "a")] 106 | Add {}, 107 | 108 | /// Perform a git commit in all repositories 109 | #[command(visible_alias = "ct")] 110 | Commit {}, 111 | 112 | /// Perform a git commit in all repositories, with predefined message 113 | #[command(visible_alias = "m")] 114 | CommitMsg {}, 115 | 116 | /// Jump to a given object 117 | #[command(subcommand, visible_alias = "j")] 118 | Jump(JumpCommands), 119 | } 120 | 121 | #[derive(Subcommand, Debug)] 122 | pub enum JumpCommands { 123 | /// Jump to repo 124 | #[command(visible_alias = "r")] 125 | Repo { category: String, name: String }, 126 | 127 | /// Jump to link 128 | #[command(visible_alias = "l")] 129 | Link { category: String, name: String }, 130 | } 131 | -------------------------------------------------------------------------------- /src/git.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | //! Git repositories 7 | 8 | use log::{debug, error, info, trace, warn}; 9 | use serde::{Deserialize, Serialize}; 10 | use spinners::{Spinner, Spinners}; 11 | use std::collections::HashMap; 12 | use std::fs::canonicalize; 13 | use std::os::unix::fs::symlink; 14 | use std::path::Path; 15 | use std::{fmt, fs, process::Command}; 16 | 17 | use crate::settings; 18 | use crate::utils::strings::{failure_str, success_str}; 19 | 20 | /// An enum containing flags that change behaviour of repos and categories 21 | #[derive(PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, Debug)] 22 | #[non_exhaustive] 23 | pub enum RepoFlags { 24 | /// If clone is set, the repository should respond to the clone subcommand 25 | Clone, 26 | /// If pull is set, the repository should respond to the pull subcommand 27 | Pull, 28 | /// If add is set, the repository should respond to the add subcommand 29 | Add, 30 | /// If commit is set, the repository should respond to the commit subcommand 31 | Commit, 32 | /// If push is set, the repository should respond to the push subcommand 33 | Push, 34 | /// If push is set, the repository should respond to the Qucik subcommand 35 | /// 36 | /// This is a shortcut for Add, Commit, Push 37 | Quick, 38 | /// If push is set, the repository should respond to the Fast and Qucik subcommand 39 | /// 40 | /// This is a shortcut for Pull, Add, Commit, Push 41 | Fast, 42 | } 43 | 44 | #[derive(PartialEq, Eq, Serialize, Deserialize, Debug)] 45 | #[non_exhaustive] 46 | pub enum RepoKinds { 47 | GitRepo, 48 | GitHubRepo, 49 | GitLabRepo, 50 | GiteaRepo, 51 | UrlRepo, 52 | Link, 53 | } 54 | 55 | /// Represents the config.toml file. 56 | /// 57 | /// For diagrams of the underlying architecture, consult ARCHITECHTURE.md 58 | #[derive(Eq, PartialEq, Debug, Serialize, Deserialize)] 59 | pub struct Config { 60 | /// map of all categories 61 | /// 62 | /// Key should conceptually be seen as the name of the category. 63 | pub categories: HashMap, 64 | } 65 | 66 | /// Represents a category of repositories 67 | /// 68 | /// This allows you to organize your repositories into categories 69 | #[derive(Eq, PartialEq, Debug, Serialize, Deserialize)] 70 | pub struct Category { 71 | #[serde(skip_serializing_if = "Option::is_none")] 72 | pub flags: Option>, // FIXME: not implemented 73 | /// map of all repos in category 74 | /// 75 | /// Key should conceptually be seen as the name of the category. 76 | #[serde(skip_serializing_if = "Option::is_none")] 77 | pub repos: Option>, 78 | 79 | /// map of all links in category 80 | /// 81 | /// Key should conceptually be seen as the name of the category. 82 | #[serde(skip_serializing_if = "Option::is_none")] 83 | pub links: Option>, 84 | } 85 | 86 | /// Contain fields for a single link. 87 | #[derive(Eq, PartialEq, Debug, Serialize, Deserialize)] 88 | pub struct Link { 89 | /// The name of the link 90 | pub name: String, 91 | pub rx: String, 92 | pub tx: String, 93 | } 94 | 95 | /// Holds a single git repository and related fields. 96 | #[derive(Eq, PartialEq, Debug, Serialize, Deserialize)] 97 | pub struct Repo { 98 | pub name: Option, 99 | pub path: Option, 100 | pub url: Option, 101 | // TODO: make default a standard GitRepo 102 | #[serde(skip_serializing_if = "Option::is_none")] 103 | pub kind: Option, // FIXME: not implemented 104 | pub flags: Option>, 105 | } 106 | 107 | /// Represents a single operation on a repository 108 | pub struct SeriesItem<'series> { 109 | /// The string to be displayed to the user 110 | pub operation: &'series str, 111 | /// The closure representing the actual operation 112 | pub closure: Box (bool)>, 113 | } 114 | 115 | #[derive(Debug)] 116 | pub enum LinkError { 117 | AlreadyLinked(String, String), 118 | DifferentLink(String, String), 119 | FileExists(String, String), 120 | BrokenSymlinkExists(String, String), 121 | FailedCreatingLink(String, String), 122 | IoError(std::io::Error), 123 | } 124 | 125 | impl std::fmt::Display for LinkError { 126 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 127 | match self { 128 | LinkError::AlreadyLinked(tx, rx) => { 129 | write!(f, "Linking {tx} -> {rx} failed: file already linked") 130 | } 131 | LinkError::DifferentLink(tx, rx) => write!( 132 | f, 133 | "Linking {tx} -> {rx} failed: link to different file exists" 134 | ), 135 | LinkError::FileExists(tx, rx) => write!(f, "Linking {tx} -> {rx} failed: file exists"), 136 | LinkError::BrokenSymlinkExists(tx, rx) => { 137 | write!(f, "Linking {tx} -> {rx} failed: broken symlink") 138 | } 139 | LinkError::FailedCreatingLink(tx, rx) => write!(f, "Linking {tx} -> {rx} failed"), 140 | LinkError::IoError(err) => write!(f, "IO Error: {err}"), 141 | } 142 | } 143 | } 144 | 145 | impl std::error::Error for LinkError { 146 | // TODO: I'm too tired to implement soucce... yawn, eepy 147 | // fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { 148 | // match self { 149 | // LinkError::AlreadyLinked(tx, rx) => Some(rx), 150 | // LinkError::DifferentLink(tx, rx) => Some(rx), 151 | // LinkError::FileExists(tx, rx) => Some(rx), 152 | // } 153 | // } 154 | } 155 | 156 | impl From for LinkError { 157 | fn from(err: std::io::Error) -> LinkError { 158 | LinkError::IoError(err) 159 | } 160 | } 161 | 162 | fn handle_file_exists(selff: &Link, tx_path: &Path, rx_path: &Path) -> Result { 163 | match rx_path.read_link() { 164 | Ok(file) if file.canonicalize()? == tx_path.canonicalize()? => { 165 | Err(LinkError::AlreadyLinked( 166 | tx_path.to_string_lossy().to_string(), 167 | rx_path.to_string_lossy().to_string(), 168 | )) 169 | } 170 | Ok(file) => Err(LinkError::DifferentLink( 171 | tx_path.to_string_lossy().to_string(), 172 | rx_path.to_string_lossy().to_string(), 173 | )), 174 | Err(error) => Err(LinkError::FileExists( 175 | tx_path.to_string_lossy().to_string(), 176 | rx_path.to_string_lossy().to_string(), 177 | )), 178 | } 179 | } 180 | 181 | impl Link { 182 | /// Creates the link from the link struct 183 | pub fn link(&self) -> Result { 184 | let tx_path: &Path = std::path::Path::new(&self.tx); 185 | let rx_path: &Path = std::path::Path::new(&self.rx); 186 | match rx_path.try_exists() { 187 | Ok(true) => handle_file_exists(self, tx_path, rx_path), 188 | Ok(false) if rx_path.is_symlink() => Err(LinkError::FileExists( 189 | tx_path.to_string_lossy().to_string(), 190 | rx_path.to_string_lossy().to_string(), 191 | )), 192 | Ok(false) => { 193 | symlink(&self.tx, &self.rx)?; 194 | Ok(true) 195 | } 196 | Err(error) => Err(LinkError::FailedCreatingLink( 197 | tx_path.to_string_lossy().to_string(), 198 | rx_path.to_string_lossy().to_string(), 199 | )), 200 | } 201 | } 202 | } 203 | 204 | impl Repo { 205 | /// Clones the repository to its specified folder. 206 | pub fn clone(&self) -> bool { 207 | if self 208 | .flags 209 | .as_ref() 210 | .expect("failed to unwrap flags") 211 | .contains(&RepoFlags::Clone) 212 | { 213 | // TODO: check if &self.name.as_ref() already exists in dir 214 | let output = Command::new("git") 215 | .current_dir(self.path.as_ref().unwrap()) 216 | .arg("clone") 217 | .arg(self.url.as_ref().unwrap()) 218 | .arg(self.name.as_ref().unwrap()) 219 | .output() 220 | .unwrap_or_else(|_| panic!("git repo failed to clone: {:?}", &self,)); 221 | output.status.success() 222 | } else { 223 | info!( 224 | "{} has clone set to false, not cloned", 225 | &self.name.as_ref().unwrap() 226 | ); 227 | false 228 | } 229 | } 230 | /// Pulls the repository if able. 231 | pub fn pull(&self) -> bool { 232 | if self 233 | .flags 234 | .as_ref() 235 | .expect("failed to unwrap flags") 236 | .iter() 237 | .any(|s| s == &RepoFlags::Pull || s == &RepoFlags::Fast) 238 | { 239 | let output = Command::new("git") 240 | .current_dir(format!( 241 | "{}{}", 242 | &self.path.as_ref().unwrap(), 243 | &self.name.as_ref().unwrap() 244 | )) 245 | .arg("pull") 246 | .output() 247 | .unwrap_or_else(|_| panic!("git repo failed to pull: {:?}", &self,)); 248 | output.status.success() 249 | } else { 250 | info!( 251 | "{} has clone set to false, not pulled", 252 | &self.name.as_ref().unwrap() 253 | ); 254 | false 255 | } 256 | } 257 | /// Adds all files in the repository. 258 | pub fn add_all(&self) -> bool { 259 | if self 260 | .flags 261 | .as_ref() 262 | .expect("failed to unwrap flags") 263 | .iter() 264 | .any(|s| s == &RepoFlags::Add || s == &RepoFlags::Quick || s == &RepoFlags::Fast) 265 | { 266 | let output = Command::new("git") 267 | .current_dir(format!( 268 | "{}{}", 269 | &self.path.as_ref().unwrap(), 270 | &self.name.as_ref().unwrap() 271 | )) 272 | .arg("add") 273 | .arg(".") 274 | .output() 275 | .unwrap_or_else(|_| panic!("git repo failed to add: {:?}", &self,)); 276 | output.status.success() 277 | } else { 278 | info!( 279 | "{} has clone set to false, not cloned", 280 | &self.name.as_ref().unwrap() 281 | ); 282 | false 283 | } 284 | } 285 | /// Tries to commit changes in the repository. 286 | /// 287 | /// # Development 288 | /// 289 | /// - FIXME: this prints extra information to terminal this is because we 290 | /// use status() instead of output(), as that makes using the native editor 291 | /// easy 292 | #[allow(dead_code)] 293 | pub fn commit(&self) -> bool { 294 | if self 295 | .flags 296 | .as_ref() 297 | .expect("failed to unwrap flags") 298 | .iter() 299 | .any(|s| s == &RepoFlags::Commit || s == &RepoFlags::Quick || s == &RepoFlags::Fast) 300 | { 301 | let status = Command::new("git") 302 | .current_dir(format!( 303 | "{}{}", 304 | &self.path.as_ref().unwrap(), 305 | &self.name.as_ref().unwrap() 306 | )) 307 | .arg("commit") 308 | .status() 309 | .unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,)); 310 | status.success() 311 | } else { 312 | info!( 313 | "{} has push set to false, not cloned", 314 | &self.name.as_ref().unwrap() 315 | ); 316 | false 317 | } 318 | } 319 | /// Tries to commit changes with a message argument. 320 | pub fn commit_with_msg(&self, msg: &str) -> bool { 321 | if self 322 | .flags 323 | .as_ref() 324 | .expect("failed to unwrap flags") 325 | .iter() 326 | .any(|s| s == &RepoFlags::Commit || s == &RepoFlags::Quick || s == &RepoFlags::Fast) 327 | { 328 | let output = Command::new("git") 329 | .current_dir(format!( 330 | "{}{}", 331 | &self.path.as_ref().unwrap(), 332 | &self.name.as_ref().unwrap() 333 | )) 334 | .arg("commit") 335 | .arg("-m") 336 | .arg(msg) 337 | .output() 338 | .unwrap_or_else(|_| panic!("git repo failed to commit: {:?}", &self,)); 339 | output.status.success() 340 | } else { 341 | info!( 342 | "{} has clone set to false, not cloned", 343 | &self.name.as_ref().unwrap() 344 | ); 345 | false 346 | } 347 | } 348 | /// Attempts to push the repository. 349 | pub fn push(&self) -> bool { 350 | if self 351 | .flags 352 | .as_ref() 353 | .expect("failed to unwrap flags") 354 | .iter() 355 | .any(|s| s == &RepoFlags::Push || s == &RepoFlags::Quick || s == &RepoFlags::Fast) 356 | { 357 | let output = Command::new("git") 358 | .current_dir(format!( 359 | "{}{}", 360 | &self.path.as_ref().unwrap(), 361 | &self.name.as_ref().unwrap() 362 | )) 363 | .arg("push") 364 | .output() 365 | .unwrap_or_else(|_| panic!("git repo failed to push: {:?}", &self,)); 366 | output.status.success() 367 | } else { 368 | info!( 369 | "{} has clone set to false, not cloned", 370 | &self.name.as_ref().unwrap() 371 | ); 372 | false 373 | } 374 | } 375 | /// Removes a repository (not implemented) 376 | /// 377 | /// Kept here as a reminder that we probably shouldn't do this 378 | fn remove() -> Result<(), std::io::Error> { 379 | // https://doc.rust-lang.org/std/fs/fn.remove_dir_all.html 380 | unimplemented!("This seems to easy to missuse/exploit"); 381 | // fs::remove_dir_all(format!("{}{}", &self.path.as_ref(), &self.name.as_ref())) 382 | } 383 | fn check_is_valid_gitrepo(&self) -> bool { 384 | if (self.name.is_none()) { 385 | eprintln!("{:?} must have name: ", self.kind); 386 | return false; 387 | } 388 | if (self.path.is_none()) { 389 | eprintln!("{:?} must have path: ", self.kind); 390 | return false; 391 | } 392 | if (self.url.is_none()) { 393 | eprintln!("{:?} must have url: ", self.kind); 394 | return false; 395 | } 396 | assert!(self.name.is_some()); 397 | assert!(self.path.is_some()); 398 | assert!(self.url.is_some()); 399 | true 400 | } 401 | fn check_is_valid_githubrepo(&self) -> bool { 402 | todo!(); 403 | } 404 | fn check_is_valid_gitlabrepo(&self) -> bool { 405 | todo!(); 406 | } 407 | fn check_is_valid_gitearepo(&self) -> bool { 408 | todo!(); 409 | } 410 | fn check_is_valid_urlrepo(&self) -> bool { 411 | todo!(); 412 | } 413 | fn check_is_valid_link(&self) -> bool { 414 | todo!(); 415 | } 416 | /// Check if Repo is a valid instance of its kind 417 | pub fn is_valid_kind(&self) -> bool { 418 | use RepoKinds::*; 419 | match &self.kind { 420 | Some(GitRepo) => self.check_is_valid_gitrepo(), 421 | Some(GitHubRepo) => self.check_is_valid_githubrepo(), 422 | Some(GitLabRepo) => self.check_is_valid_gitlabrepo(), 423 | Some(GiteaRepo) => self.check_is_valid_gitearepo(), 424 | Some(UrlRepo) => self.check_is_valid_urlrepo(), 425 | Some(Link) => self.check_is_valid_link(), 426 | Some(kind) => { 427 | panic!("kind {kind:?} not implemented"); 428 | false 429 | } 430 | None => { 431 | println!("unknown kind {:?}", self.kind); 432 | false 433 | } 434 | } 435 | } 436 | } 437 | 438 | /// run_series runs a closure series on a Config struct 439 | /// 440 | /// # Examples 441 | /// 442 | /// 443 | /// ``` 444 | /// use seidr::git; 445 | /// use seidr::git::Repo; 446 | /// use seidr::git::Config; 447 | /// use std::env::current_dir; 448 | /// use seidr::git::SeriesItem; 449 | /// use relative_path::RelativePath; 450 | /// 451 | /// let root = current_dir().expect("failed to get current dir"); 452 | /// let config = Config::new( 453 | /// &RelativePath::new("./src/test/config.yaml") 454 | /// .to_logical_path(root) 455 | /// .into_os_string() 456 | /// .into_string() 457 | /// .expect("failed to turnn config into string"), 458 | /// ); 459 | /// 460 | /// let series: Vec = vec![ 461 | /// SeriesItem { 462 | /// operation: "pull", 463 | /// closure: Box::new(move |repo: &Repo| repo.pull()), 464 | /// }, 465 | /// SeriesItem { 466 | /// operation: "add", 467 | /// closure: Box::new(move |repo: &Repo| repo.add_all()), 468 | /// }, 469 | /// SeriesItem { 470 | /// operation: "commit", 471 | /// closure: Box::new(move |repo: &Repo| repo.commit()), 472 | /// }, 473 | /// SeriesItem { 474 | /// operation: "push", 475 | /// closure: Box::new(move |repo: &Repo| repo.push()), 476 | /// }, 477 | /// ]; 478 | /// 479 | /// // If we don't care if the series steps fail 480 | /// run_series!(config, series); 481 | /// 482 | /// // If we want to skip repo as soon as a step fails 483 | /// run_series!(config, series, true); 484 | /// ``` 485 | #[macro_export] 486 | macro_rules! run_series { 487 | ($conf:ident, $closures:ident) => { 488 | $conf.all_on_all($closures, false); 489 | }; 490 | ($conf:ident, $closures:ident, $stop_on_err:tt) => { 491 | $conf.all_on_all($closures, $stop_on_err); 492 | }; 493 | } 494 | 495 | impl Config { 496 | /// Loads the configuration toml from a path in to the Config struct. 497 | pub fn new(path: &String) -> Self { 498 | debug!("initializing new Config struct"); 499 | let yaml = fs::read_to_string(path).unwrap_or_else(|_| { 500 | panic!("Should have been able to read the file: path -> {:?}", path,) 501 | }); 502 | debug!("deserialized yaml from config file"); 503 | serde_yaml::from_str(&yaml).unwrap_or_else(|_| { 504 | panic!( 505 | "Should have been able to deserialize yaml config: path -> {:?}", 506 | path, 507 | ) 508 | }) 509 | } 510 | /// Runs associated function on all repos in config 511 | /// 512 | /// NOTE: currently unused 513 | fn on_all(&self, f: F) 514 | where 515 | F: Fn(&Repo), 516 | { 517 | for category in self.categories.values() { 518 | for (_, repo) in category.repos.as_ref().expect("failed to get repos").iter() { 519 | f(repo); 520 | } 521 | } 522 | } 523 | // /// Runs associated function on all repos in config 524 | // fn on_all_spinner(&self, op: &str, f: F) 525 | // where 526 | // F: Fn(&Repo) -> bool, 527 | // { 528 | // for category in self.categories.values() { 529 | // for (_, repo) in category.repos.as_ref().expect("failed to get repos").iter() { 530 | // if !settings::QUIET.load(std::sync::atomic::Ordering::Relaxed) { 531 | // let mut sp = Spinner::new(Spinners::Dots10, format!("{}: {}", repo.name.as_ref(), op)); 532 | // if f(repo) { 533 | // sp.stop_and_persist(success_str(), format!("{}: {}", repo.name.as_ref(), op)); 534 | // } else { 535 | // sp.stop_and_persist(failure_str(), format!("{}: {}", repo.name.as_ref(), op)); 536 | // } 537 | // } else { 538 | // f(repo); 539 | // } 540 | // } 541 | // } 542 | // } 543 | /// Runs associated function on all repos in config 544 | fn on_all_repos_spinner(&self, op: &str, f: F) 545 | where 546 | F: Fn(&Repo) -> bool, 547 | { 548 | for category in self.categories.values() { 549 | match category.repos.as_ref() { 550 | Some(repos) => { 551 | for repo in repos.values() { 552 | if !settings::QUIET.load(std::sync::atomic::Ordering::Relaxed) { 553 | let mut sp = Spinner::new( 554 | Spinners::Dots10, 555 | format!("{}: {}", repo.name.as_ref().unwrap(), op), 556 | ); 557 | if f(repo) { 558 | sp.stop_and_persist( 559 | success_str(), 560 | format!("{}: {}", repo.name.as_ref().unwrap(), op), 561 | ); 562 | } else { 563 | sp.stop_and_persist( 564 | failure_str(), 565 | format!("{}: {}", repo.name.as_ref().unwrap(), op), 566 | ); 567 | } 568 | } else { 569 | f(repo); 570 | } 571 | } 572 | } 573 | None => continue, 574 | }; 575 | } 576 | } 577 | /// Runs associated function on all links in config 578 | fn on_all_links_spinner(&self, op: &str, f: F) 579 | where 580 | F: Fn(&Link) -> Result, 581 | { 582 | for category in self.categories.values() { 583 | match category.links.as_ref() { 584 | Some(links) => { 585 | for link in links.values() { 586 | if !settings::QUIET.load(std::sync::atomic::Ordering::Relaxed) { 587 | let mut sp = 588 | Spinner::new(Spinners::Dots10, format!("{}: {}", link.name, op)); 589 | match f(link) { 590 | Ok(_) => sp.stop_and_persist( 591 | success_str(), 592 | format!("{}: {}", link.name, op), 593 | ), 594 | Err(e @ LinkError::AlreadyLinked(_, _)) => { 595 | sp.stop_and_persist(success_str(), format!("{e}")) 596 | } 597 | Err(e @ LinkError::DifferentLink(_, _)) => { 598 | sp.stop_and_persist(failure_str(), format!("{e}")) 599 | } 600 | Err(e @ LinkError::FileExists(_, _)) => { 601 | sp.stop_and_persist(failure_str(), format!("{e}")) 602 | } 603 | Err(e @ LinkError::BrokenSymlinkExists(_, _)) => { 604 | sp.stop_and_persist(failure_str(), format!("{e}")) 605 | } 606 | Err(e @ LinkError::FailedCreatingLink(_, _)) => { 607 | sp.stop_and_persist(failure_str(), format!("{e}")) 608 | } 609 | Err(e @ LinkError::IoError(_)) => sp.stop_and_persist( 610 | failure_str(), 611 | format!("{}: {op}, {e}", link.name), 612 | ), 613 | Err(e) => sp.stop_and_persist(failure_str(), format!("{e}")), 614 | _ => sp.stop_and_persist( 615 | failure_str(), 616 | format!("{}: {}", link.name, op), 617 | ), 618 | } 619 | } else { 620 | f(link); 621 | } 622 | } 623 | } 624 | None => continue, 625 | }; 626 | } 627 | } 628 | /// Runs associated function on all repos in config 629 | /// 630 | /// Unlike `series_on_all`, this does not stop if it encounters an error 631 | /// 632 | /// # Usage 633 | /// 634 | /// Here is an example of how an associated method could use this function. 635 | /// 636 | /// ``` 637 | /// # use seidr::git::Repo; 638 | /// # use seidr::git::SeriesItem; 639 | /// 640 | /// let series: Vec = vec![ 641 | /// SeriesItem { 642 | /// operation: "pull", 643 | /// closure: Box::new(move |repo: &Repo| repo.pull()), 644 | /// }, 645 | /// SeriesItem { 646 | /// operation: "add", 647 | /// closure: Box::new(move |repo: &Repo| repo.add_all()), 648 | /// }, 649 | /// SeriesItem { 650 | /// operation: "commit", 651 | /// closure: Box::new(move |repo: &Repo| repo.commit()), 652 | /// }, 653 | /// SeriesItem { 654 | /// operation: "push", 655 | /// closure: Box::new(move |repo: &Repo| repo.push()), 656 | /// }, 657 | /// ]; 658 | /// ``` 659 | pub fn all_on_all(&self, closures: Vec, break_on_err: bool) { 660 | // HACK: creates a empty repo, that is used if a category doesn't have 661 | // any repos or don't define the repo field 662 | let tmp: HashMap = HashMap::new(); 663 | 664 | for category in self.categories.values() { 665 | // HACK: if the repo doesn't exist here, we inject tmp 666 | for (_, repo) in category.repos.as_ref().unwrap_or(&tmp).iter() { 667 | use RepoKinds::*; 668 | match &repo.kind { 669 | Some(GitRepo) => { 670 | for instruction in &closures { 671 | let f = &instruction.closure; 672 | let op = instruction.operation; 673 | if !settings::QUIET.load(std::sync::atomic::Ordering::Relaxed) { 674 | let mut sp = Spinner::new( 675 | Spinners::Dots10, 676 | format!("{}: {}", repo.name.as_ref().unwrap(), op), 677 | ); 678 | if f(repo) { 679 | sp.stop_and_persist( 680 | success_str(), 681 | format!("{}: {}", repo.name.as_ref().unwrap(), op), 682 | ); 683 | } else { 684 | sp.stop_and_persist( 685 | failure_str(), 686 | format!("{}: {}", repo.name.as_ref().unwrap(), op), 687 | ); 688 | if break_on_err { 689 | break; 690 | } 691 | } 692 | } else { 693 | f(repo); 694 | } 695 | } 696 | } 697 | None => { 698 | println!("unknown kind {:?}", repo.kind); 699 | } 700 | Some(kind) => { 701 | println!("unknown kind {kind:?}"); 702 | } 703 | } 704 | } 705 | } 706 | } 707 | pub fn get_repo(&self, cat_name: &str, repo_name: &str, f: F) 708 | where 709 | F: FnOnce(&Repo), 710 | { 711 | f(self 712 | .categories 713 | .get(cat_name) 714 | .expect("failed to get category") 715 | .repos 716 | .as_ref() 717 | .expect("failed to get repo") 718 | .get(repo_name) 719 | .expect("failed to get category")); 720 | } 721 | pub fn get_link(&self, cat_name: &str, link_name: &str, f: F) 722 | where 723 | F: FnOnce(&Link), 724 | { 725 | f(self 726 | .categories 727 | .get(cat_name) 728 | .expect("failed to get category") 729 | .links 730 | .as_ref() 731 | .expect("failed to get repo") 732 | .get(link_name) 733 | .expect("failed to get category")); 734 | } 735 | /// Tries to pull all repositories, skips if fail. 736 | pub fn pull_all(&self) { 737 | debug!("exectuting pull_all"); 738 | self.on_all_repos_spinner("pull", Repo::pull); 739 | } 740 | /// Tries to clone all repossitories, skips if fail. 741 | pub fn clone_all(&self) { 742 | debug!("exectuting clone_all"); 743 | self.on_all_repos_spinner("clone", Repo::clone); 744 | } 745 | /// Tries to add all work in all repossitories, skips if fail. 746 | pub fn add_all(&self) { 747 | debug!("exectuting clone_all"); 748 | self.on_all_repos_spinner("add", Repo::add_all); 749 | } 750 | /// Tries to commit all repossitories one at a time, skips if fail. 751 | pub fn commit_all(&self) { 752 | debug!("exectuting clone_all"); 753 | self.on_all_repos_spinner("commit", Repo::commit); 754 | } 755 | /// Tries to commit all repossitories with msg, skips if fail. 756 | pub fn commit_all_msg(&self, msg: &str) { 757 | debug!("exectuting clone_all"); 758 | self.on_all_repos_spinner("commit", |repo| repo.commit_with_msg(msg)); 759 | } 760 | /// Tries to pull, add all, commit with msg "quick commit", and push all 761 | /// repositories, skips if fail. 762 | pub fn quick(&self, msg: &'static str) { 763 | debug!("exectuting quick"); 764 | let series: Vec = vec![ 765 | SeriesItem { 766 | operation: "pull", 767 | closure: Box::new(Repo::pull), 768 | }, 769 | SeriesItem { 770 | operation: "add", 771 | closure: Box::new(Repo::add_all), 772 | }, 773 | SeriesItem { 774 | operation: "commit", 775 | closure: Box::new(move |repo: &Repo| repo.commit_with_msg(msg)), 776 | }, 777 | SeriesItem { 778 | operation: "push", 779 | closure: Box::new(Repo::push), 780 | }, 781 | ]; 782 | run_series!(self, series); 783 | } 784 | /// Tries to pull, add all, commit with msg "quick commit", and push all 785 | /// repositories, skips if fail. 786 | pub fn fast(&self, msg: &'static str) { 787 | debug!("exectuting fast"); 788 | let series: Vec = vec![ 789 | SeriesItem { 790 | operation: "pull", 791 | closure: Box::new(Repo::pull), 792 | }, 793 | SeriesItem { 794 | operation: "add", 795 | closure: Box::new(Repo::add_all), 796 | }, 797 | SeriesItem { 798 | operation: "commit", 799 | closure: Box::new(move |repo: &Repo| repo.commit_with_msg(msg)), 800 | }, 801 | SeriesItem { 802 | operation: "push", 803 | closure: Box::new(Repo::push), 804 | }, 805 | ]; 806 | run_series!(self, series, true); 807 | } 808 | /// Tries to link all repositories, skips if fail. 809 | pub fn link_all(&self) { 810 | debug!("exectuting link_all"); 811 | self.on_all_links_spinner("link", Link::link); 812 | } 813 | } 814 | -------------------------------------------------------------------------------- /src/lib.rs.old: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | #[allow(unused)] 7 | pub mod git; 8 | #[allow(unused)] 9 | mod settings; 10 | #[allow(unused)] 11 | mod utils; 12 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | //! A Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow. 7 | //! 8 | //! # What is? 9 | //! 10 | //! A Rust GitOps/symlinkfarm orchestrator inspired by GNU Stow. Useful for dealing 11 | //! with "dotfiles", and with git support as a first class feature. Configuration is 12 | //! done throug a single yaml file, giving it a paradigm that should bring joy to 13 | //! those that use declarative operating systems and package managers. 14 | //! 15 | //! Although this isn't really a case where it matters *that* much for performance, 16 | //! being written in rust instead of e.g. /janky/ scripting languages does also mean 17 | //! it is snappy and reliable, and the /extensive/ testing helps ensure regressions 18 | //! aren't introduced. 19 | //! 20 | //! That said, we're in 0.0.Z, *here be dragons* for now. 21 | // #![feature(unsized_tuple_coercion)] 22 | 23 | extern crate log; 24 | extern crate pretty_env_logger; 25 | 26 | #[allow(unused)] 27 | mod cli; 28 | #[allow(unused)] 29 | mod git; 30 | #[allow(unused)] 31 | mod settings; 32 | #[allow(unused)] 33 | mod utils; 34 | 35 | use cli::{Args, Commands, JumpCommands}; 36 | use git::Config; 37 | 38 | use clap::Parser; 39 | 40 | #[allow(unused)] 41 | use log::{debug, error, info, trace, warn}; 42 | 43 | use std::sync::atomic::Ordering; 44 | 45 | /// The main loop of the binary 46 | /// 47 | /// Here, we handle parsing the configuration file, as well as matching commands 48 | /// to the relavant operations. 49 | fn main() { 50 | pretty_env_logger::init(); 51 | let mut args = Args::parse(); 52 | let config = Config::new(&args.config); 53 | 54 | // Input from -m flag is stored here, this is just used to construct the 55 | // persistent box 56 | let mut message_input: String = String::new(); 57 | 58 | match &args { 59 | args if args.license => println!("{}", utils::strings::INTERACTIVE_LICENSE), 60 | args if args.warranty => println!("{}", utils::strings::INTERACTIVE_WARRANTY), 61 | args if args.code_of_conduct => println!("{}", utils::strings::INTERACTIVE_COC), 62 | args if args.quiet => settings::QUIET.store(true, Ordering::Relaxed), 63 | args if args.no_emoji => settings::EMOJIS.store(true, Ordering::Relaxed), 64 | args if args.unlink => settings::UNLINK.store(true, Ordering::Relaxed), 65 | args if args.force => settings::FORCE.store(true, Ordering::Relaxed), 66 | args if args.message.is_some() => message_input = args.message.clone().unwrap(), 67 | _ => (), 68 | } 69 | 70 | let message = Box::leak(message_input.into_boxed_str()); 71 | 72 | match &mut args.command { 73 | Some(Commands::Link {}) => { 74 | config.link_all(); 75 | } 76 | // NOTE: This implements "sub-subcommand"-like matching on repository, 77 | // name, and additional data for a subcommand 78 | // TODO: generalize for reuse by all commands that operate on repo->name->msg 79 | // 80 | // What we want: 81 | // - seidr quick 82 | // - seidr quick category 83 | // - seidr quick category repository 84 | // - seidr quick -m "message" 85 | // - seidr quick category -m "message" 86 | // - seidr quick category repo -m "hi" 87 | // 88 | // What we are implementing: 89 | // - [x] seidr quick 90 | // - [ ] seidr quick category 91 | // - [ ] seidr quick category repository 92 | // - [ ] seidr quick category repository "stuff" 93 | // 94 | // Roadmap: 95 | // - [-] basic command parsing 96 | // - [ ] lacks -m flag 97 | // - [ ] ability to run command on repos in category 98 | // - [ ] ability to run command on single repo 99 | Some(Commands::Quick { category, repo }) => match (&category, &repo) { 100 | // - seidr quick 101 | (None, None) => { 102 | config.quick(message); 103 | } 104 | // - [ ] seidr quick category 105 | (category, None) => { 106 | println!("{}", category.as_ref().unwrap()); 107 | todo!(); 108 | } 109 | (category, repo) => { 110 | println!("{} {}", category.as_ref().unwrap(), repo.as_ref().unwrap()); 111 | todo!(); 112 | } // // - [ ] seidr quick category categorysitory "stuff" 113 | // (category, repo) => { 114 | // println!("{} {}", category.as_ref().unwrap(), repo.as_ref().unwrap(),); 115 | // todo!(); 116 | // } 117 | }, 118 | Some(Commands::Fast {}) => { 119 | config.fast(message); 120 | } 121 | Some(Commands::Clone {}) => { 122 | config.clone_all(); 123 | } 124 | Some(Commands::Pull {}) => { 125 | config.pull_all(); 126 | } 127 | Some(Commands::Add {}) => { 128 | config.add_all(); 129 | } 130 | Some(Commands::Commit {}) => { 131 | config.commit_all(); 132 | } 133 | Some(Commands::CommitMsg {}) => { 134 | config.commit_all_msg(message); 135 | } 136 | Some(Commands::Jump(cmd)) => match cmd { 137 | JumpCommands::Repo { category, name } => { 138 | config.get_repo(category, name, |repo| { 139 | println!( 140 | "{}{}", 141 | repo.path.as_ref().unwrap(), 142 | repo.name.as_ref().unwrap() 143 | ); 144 | }); 145 | } 146 | JumpCommands::Link { category, name } => { 147 | config.get_link(category, name, |link| println!("{}", link.tx)); 148 | } 149 | }, 150 | None => (), 151 | } 152 | trace!("{:?}", config); 153 | } 154 | 155 | #[cfg(test)] 156 | mod config { 157 | use crate::*; 158 | use git::RepoFlags::{Clone, Push}; 159 | use git::{Category, Repo}; 160 | use relative_path::RelativePath; 161 | use std::collections::HashMap; 162 | use std::env::current_dir; 163 | use std::fs::File; 164 | use std::io::prelude::*; 165 | #[test] 166 | fn init_config() { 167 | let _config = Config { 168 | categories: HashMap::new(), 169 | }; 170 | } 171 | #[test] 172 | fn init_config_populate() { 173 | let default_category = Category { 174 | flags: Some(vec![]), 175 | repos: Some(HashMap::new()), 176 | links: Some(HashMap::new()), 177 | }; 178 | let mut config = Config { 179 | categories: HashMap::new(), 180 | }; 181 | config 182 | .categories 183 | .insert(format!("{}", 0).to_string(), default_category); 184 | for i in 0..=5 { 185 | config 186 | .categories 187 | .get_mut(&format!("{}", 0).to_string()) 188 | .expect("category not found") 189 | .repos 190 | .as_mut() 191 | .expect("failed to get repo") 192 | .insert( 193 | format!("{}", i).to_string(), 194 | Repo { 195 | name: Some("test repo".to_string()), 196 | path: Some("/tmp".to_string()), 197 | url: Some("https://github.com/cafkafk/seidr".to_string()), 198 | flags: Some(vec![Clone, Push]), 199 | kind: None, 200 | }, 201 | ); 202 | } 203 | } 204 | #[test] 205 | fn read_config_populate() { 206 | let _config = Config::new(&RelativePath::new("./src/test/config.yaml").to_string()); 207 | } 208 | #[test] 209 | fn write_config() { 210 | let root = current_dir().expect("failed to get current dir"); 211 | let config = Config::new( 212 | &RelativePath::new("./src/test/config.yaml") 213 | .to_logical_path(&root) 214 | .into_os_string() 215 | .into_string() 216 | .expect("failed to turn config into string"), 217 | ); 218 | 219 | let mut test_file = File::create( 220 | RelativePath::new("./src/test/test.yaml") 221 | .to_logical_path(&root) 222 | .into_os_string() 223 | .into_string() 224 | .expect("failed to turn config into string"), 225 | ) 226 | .expect("failed to create test file"); 227 | let contents = serde_yaml::to_string(&config).expect("failed to turn config into string"); 228 | test_file 229 | .write_all(contents.as_bytes()) 230 | .expect("failed to write contents of config into file"); 231 | 232 | let test_config = Config::new(&RelativePath::new("./src/test/test.yaml").to_string()); 233 | assert_eq!(config, test_config); 234 | } 235 | #[allow(dead_code)] 236 | fn get_category<'cat>(config: &'cat Config, name: &'cat str) -> &'cat Category { 237 | config.categories.get(name).expect("failed to get category") 238 | } 239 | #[test] 240 | fn is_config_readable() { 241 | let root = current_dir().expect("failed to get current dir"); 242 | let config = Config::new( 243 | &RelativePath::new("./src/test/config.yaml") 244 | .to_logical_path(root) 245 | .into_os_string() 246 | .into_string() 247 | .expect("failed to turnn config into string"), 248 | ); 249 | 250 | let _flags = vec![Clone, Push]; 251 | // NOTE not very extensive 252 | #[allow(clippy::bool_assert_comparison)] 253 | { 254 | (&config).get_repo("config", "qmk_firmware", |repo| { 255 | assert_eq!(repo.name.as_ref().unwrap(), "qmk_firmware"); 256 | assert_eq!(repo.path.as_ref().unwrap(), "/home/ces/org/src/git/"); 257 | assert_eq!( 258 | repo.url.as_ref().unwrap(), 259 | "git@github.com:cafkafk/qmk_firmware.git" 260 | ); 261 | }); 262 | (&config).get_link("stuff", "seidr", |link| { 263 | assert_eq!(link.name, "seidr"); 264 | assert_eq!(link.tx, "/home/ces/.dots/seidr"); 265 | assert_eq!(link.rx, "/home/ces/.config/seidr"); 266 | }); 267 | } 268 | } 269 | #[test] 270 | fn test_validators_config() { 271 | use crate::git::SeriesItem; 272 | let root = current_dir().expect("failed to get current dir"); 273 | let config = Config::new( 274 | &RelativePath::new("./src/test/config.yaml") 275 | .to_logical_path(&root) 276 | .into_os_string() 277 | .into_string() 278 | .expect("failed to turn config into string"), 279 | ); 280 | let series: Vec = vec![SeriesItem { 281 | operation: "is_valid_kind", 282 | closure: Box::new(Repo::is_valid_kind), 283 | }]; 284 | run_series!(config, series, true); 285 | } 286 | #[test] 287 | #[should_panic] 288 | fn test_validators_fail() { 289 | use crate::git::SeriesItem; 290 | let default_category = Category { 291 | flags: Some(vec![]), 292 | repos: Some(HashMap::new()), 293 | links: Some(HashMap::new()), 294 | }; 295 | let mut config = Config { 296 | categories: HashMap::new(), 297 | }; 298 | config 299 | .categories 300 | .insert(format!("{}", 0).to_string(), default_category); 301 | for i in 0..=5 { 302 | config 303 | .categories 304 | .get_mut(&format!("{}", 0).to_string()) 305 | .expect("category not found") 306 | .repos 307 | .as_mut() 308 | .expect("failed to get repo") 309 | .insert( 310 | format!("{}", i).to_string(), 311 | // WE create a broken repo 312 | Repo { 313 | name: None, 314 | path: Some("/tmp".to_string()), 315 | url: Some("https://github.com/cafkafk/seidr".to_string()), 316 | flags: Some(vec![Clone, Push]), 317 | kind: Some(crate::git::RepoKinds::GitRepo), 318 | }, 319 | ); 320 | } 321 | let series: Vec = vec![SeriesItem { 322 | operation: "is_valid_kind", 323 | closure: Box::new(Repo::is_valid_kind), 324 | }]; 325 | run_series!(config, series, true); 326 | } 327 | } 328 | 329 | /* FIXME Unable to test with networking inside flake 330 | #[cfg(test)] 331 | mod repo_actions { 332 | use crate::*; 333 | use git::Repo; 334 | use relative_path::RelativePath; 335 | use std::env::current_dir; 336 | use std::process::Command; 337 | #[test] 338 | #[allow(clippy::redundant_clone)] 339 | fn test_repo_actions() { 340 | let test_repo_name: String = "test".to_string(); 341 | let root = current_dir().unwrap(); 342 | let test_repo_dir: String = RelativePath::new("./src/test") 343 | .to_logical_path(&root) 344 | .into_os_string() 345 | .into_string() 346 | .unwrap(); 347 | let test_repo_url: String = "git@github.com:cafkafk/test.git".to_string(); 348 | println!("{}", test_repo_dir); 349 | let mut config = Config { 350 | repos: vec![], 351 | links: vec![], 352 | }; 353 | let repo = Repo { 354 | name: test_repo_name.to_owned(), 355 | path: test_repo_dir.to_owned(), 356 | url: test_repo_url.to_owned(), 357 | clone: true, 358 | }; 359 | config.repos.push(repo); 360 | // BUG FIXME can't do this in flake 361 | // should have a good alternative 362 | // config.clone_all(); 363 | // config.pull_all(); 364 | for r in config.repos.iter() { 365 | Command::new("touch") 366 | .current_dir(&(r.path.to_owned() + &r.name)) 367 | .arg("test") 368 | .status() 369 | .expect("failed to create test file"); 370 | } 371 | config.add_all(); 372 | config.commit_all_msg(&"test".to_string()); 373 | } 374 | } 375 | */ 376 | -------------------------------------------------------------------------------- /src/settings.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | use std::sync::atomic::AtomicBool; 7 | 8 | pub static QUIET: AtomicBool = AtomicBool::new(false); 9 | 10 | pub static EMOJIS: AtomicBool = AtomicBool::new(false); 11 | 12 | pub static UNLINK: AtomicBool = AtomicBool::new(false); 13 | 14 | pub static FORCE: AtomicBool = AtomicBool::new(false); 15 | -------------------------------------------------------------------------------- /src/test/config.yaml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | categories: 7 | config: 8 | flags: [] 9 | repos: 10 | qmk_firmware: 11 | name: qmk_firmware 12 | path: /home/ces/org/src/git/ 13 | url: git@github.com:cafkafk/qmk_firmware.git 14 | kind: GitRepo 15 | flags: [Clone, Push] 16 | starship: 17 | name: starship 18 | path: /home/ces/org/src/git/ 19 | url: https://github.com/starship/starship.git 20 | kind: GitRepo 21 | flags: [Clone, Push] 22 | utils: 23 | repos: 24 | seidr: 25 | name: seidr 26 | path: /home/ces/.dots/ 27 | url: git@github.com:cafkafk/seidr.git 28 | kind: GitRepo 29 | flags: [Clone, Push] 30 | li: 31 | name: li 32 | path: /home/ces/org/src/git/ 33 | url: git@github.com:cafkafk/li.git 34 | kind: GitRepo 35 | flags: [Clone, Push] 36 | empty: 37 | stuff: 38 | flags: [] 39 | repos: 40 | seidr: 41 | name: seidr 42 | path: /home/ces/.dots/ 43 | kind: GitRepo 44 | url: git@github.com:cafkafk/seidr.git 45 | li: 46 | name: li 47 | path: /home/ces/org/src/git/ 48 | kind: GitRepo 49 | url: git@github.com:cafkafk/li.git 50 | links: 51 | seidr: 52 | name: seidr 53 | rx: /home/ces/.config/seidr 54 | tx: /home/ces/.dots/seidr 55 | starship: 56 | name: starship 57 | rx: /home/ces/.config/starship.toml 58 | tx: /home/ces/.dots/starship.toml 59 | fluff: 60 | flags: [] 61 | links: 62 | seidr: 63 | name: seidr 64 | rx: /home/ces/.config/seidr 65 | tx: /home/ces/.dots/seidr 66 | starship: 67 | name: starship 68 | rx: /home/ces/.config/starship.toml 69 | tx: /home/ces/.dots/starship.toml 70 | -------------------------------------------------------------------------------- /src/utils.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | //! Sublibrary for useful functions 7 | 8 | pub mod dir; 9 | pub mod strings; 10 | -------------------------------------------------------------------------------- /src/utils/dir.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | //! Nice helpers for dealing with filesystem environment. 7 | 8 | #![feature(stmt_expr_attributes)] 9 | use log::{debug, error, info, trace, warn}; 10 | 11 | use std::env; 12 | use std::path::Path; 13 | 14 | /// Returns the users current dir 15 | /// 16 | /// Does not work on Windows 17 | pub fn current_dir() -> String { 18 | #[allow(deprecated)] // NOTE we don't care about windows , we don't support it 19 | env::current_dir() 20 | .expect("Failed to get current_dir") 21 | .into_os_string() 22 | .into_string() 23 | .expect("Failed to turn home_dir into a valid string") 24 | } 25 | 26 | /// Returns the users home dir 27 | /// 28 | /// Does not work on Windows 29 | pub fn home_dir() -> String { 30 | #[allow(deprecated)] // NOTE we don't care about windows , we don't support it 31 | env::home_dir() 32 | .expect("Failed to get home_dir") 33 | .into_os_string() 34 | .into_string() 35 | .expect("Failed to turn home_dir into a valid string") 36 | } 37 | 38 | /// Changes working directory into a repository. 39 | /// 40 | /// WARNING: NOT THREAD SAFE 41 | fn change_dir_repo(path: &str, name: &str) { 42 | let mut full_path: String = String::new(); 43 | full_path.push_str(path); 44 | full_path.push_str(name); 45 | let root = Path::new(&full_path); 46 | println!("{}", root.display()); 47 | assert!(env::set_current_dir(root).is_ok()); 48 | debug!( 49 | "Successfully changed working directory to {}!", 50 | root.display() 51 | ); 52 | } 53 | 54 | /// Changes working directory to outside of the repo. 55 | /// 56 | /// WARNING: NOT THREAD SAFE 57 | fn change_dir(path: &str) { 58 | let root = Path::new(path); 59 | assert!(env::set_current_dir(root).is_ok()); 60 | debug!( 61 | "Successfully changed working directory to {}!", 62 | root.display() 63 | ); 64 | } 65 | 66 | /// Returns the users home directory (on unix like only) 67 | macro_rules! current_dir { 68 | () => { 69 | env::current_dir() 70 | .expect("Failed to get current_dir") 71 | .into_os_string() 72 | .into_string() 73 | .expect("Failed to turn home_dir into a valid string") 74 | }; 75 | } 76 | 77 | /// Returns the users home directory (on unix like only) 78 | macro_rules! home_dir { 79 | () => { 80 | #[allow(deprecated)] // NOTE we don't care about windows , we don't support it 81 | env::home_dir() 82 | .expect("Failed to get home_dir") 83 | .into_os_string() 84 | .into_string() 85 | .expect("Failed to turn home_dir into a valid string") 86 | }; 87 | } 88 | -------------------------------------------------------------------------------- /src/utils/strings.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | //! Module for chunk of text 7 | //! 8 | //! Ideally, at a VERY long term scale, this should be a nice pattern for 9 | //! possible translations. 10 | 11 | use std::sync::atomic::Ordering; 12 | 13 | use crate::settings; 14 | 15 | /// Contains the notice for interactive programs from the GPLv3's "How to Apply 16 | /// These Terms to Your New Programs" 17 | pub const INTERACTIVE_NOTICE: &str = "\ 18 | seidr Copyright (C) 2023 Christina Sørensen 19 | 20 | This program comes with ABSOLUTELY NO WARRANTY; for details type `seidr 21 | --warranty'. This is free software, and you are welcome to redistribute it under 22 | certain conditions; type `seidr --license' for details. "; 23 | 24 | /// Contains the license part of the long notice for interactive programs from 25 | /// the GPLv3's "How to Apply These Terms to Your New Programs" 26 | pub const INTERACTIVE_LICENSE: &str = "\ 27 | This program is free software: you can redistribute it and/or modify 28 | it under the terms of the GNU General Public License as published by 29 | the Free Software Foundation, either version 3 of the License, or 30 | (at your option) any later version. 31 | "; 32 | 33 | /// Contains the warranty part of the long notice for interactive programs from 34 | /// the GPLv3's "How to Apply These Terms to Your New Programs" 35 | pub const INTERACTIVE_WARRANTY: &str = "\ 36 | This program is distributed in the hope that it will be useful, 37 | but WITHOUT ANY WARRANTY; without even the implied warranty of 38 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 39 | GNU General Public License for more details. 40 | "; 41 | 42 | pub const INTERACTIVE_COC: &str = "\ 43 | In the interest of fostering an open and welcoming environment, we as 44 | contributors and maintainers pledge to making participation in our project and 45 | our community a harassment-free experience for everyone, regardless of age, body 46 | size, disability, ethnicity, gender identity and expression, level of 47 | experience, nationality, personal appearance, race, religion, or sexual identity 48 | and orientation. For more, see http://contributor-covenant.org/version/1/4"; 49 | 50 | /// Contains the message for quick commit subcommand 51 | pub const QUICK_COMMIT: &str = "git: quick commit"; 52 | 53 | /// Contains the message for fast commit subcommand 54 | pub const FAST_COMMIT: &str = "git: fast commit"; 55 | 56 | /// Success emoji 57 | pub const SUCCESS_EMOJI: &str = "✔"; 58 | 59 | /// Failure emoji 60 | pub const FAILURE_EMOJI: &str = "❌"; 61 | 62 | /// Success string 63 | pub const SUCCESS_STRING: &str = "SUCC"; 64 | 65 | /// Failure string 66 | pub const FAILURE_STRING: &str = "FAIL"; 67 | 68 | pub fn success_str() -> &'static str { 69 | if settings::EMOJIS.load(Ordering::Relaxed) { 70 | SUCCESS_STRING 71 | } else { 72 | SUCCESS_EMOJI 73 | } 74 | } 75 | 76 | pub fn failure_str() -> &'static str { 77 | if settings::EMOJIS.load(Ordering::Relaxed) { 78 | FAILURE_STRING 79 | } else { 80 | FAILURE_EMOJI 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /tests/main.rs: -------------------------------------------------------------------------------- 1 | // SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | // SPDX-FileContributor: Christina Sørensen 3 | // 4 | // SPDX-License-Identifier: AGPL-3.0-only 5 | 6 | #[test] 7 | fn main() { 8 | assert!(true); 9 | } 10 | -------------------------------------------------------------------------------- /treefmt.nix: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: 2023 Christina Sørensen 2 | # SPDX-FileContributor: Christina Sørensen 3 | # 4 | # SPDX-License-Identifier: AGPL-3.0-only 5 | { 6 | projectRootFile = "Cargo.toml"; 7 | programs = { 8 | alejandra.enable = true; # nix 9 | rustfmt.enable = true; # rust 10 | shellcheck.enable = true; # bash/shell 11 | deadnix.enable = true; # find dead nix code 12 | taplo.enable = true; # toml 13 | yamlfmt.enable = true; # yaml 14 | }; 15 | } 16 | --------------------------------------------------------------------------------