Skip to content

Commit 3d7bbb3

Browse files
committedJun 17, 2024
feat: First initial setup for a Rust CLI
1 parent 84817bb commit 3d7bbb3

17 files changed

+690
-0
lines changed
 

‎.editorconfig

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Unix-style newlines with a newline ending every file
7+
[*]
8+
end_of_line = lf
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.{json,yaml,yml}]
14+
indent_size = 2
15+
16+
[*.nix]
17+
indent_size = 2

‎.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake ./nix#default

‎.githooks/.ignore.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
patterns:
2+
- "**/*.md"
3+
- "**/*export-staged"

‎.githooks/.namespace

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dotfiles

‎.githooks/.shared.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
version: 1
2+
urls:
3+
- https://github.com/gabyx/githooks-shell.git@main
4+
- https://github.com/gabyx/githooks-docs.git@main
5+
- https://github.com/gabyx/githooks-configs.git@main

‎.githooks/README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Githooks
2+
3+
This project uses [Githooks](https://github.com/gabyx/githooks), that allows running [Git hooks](https://git-scm.com/docs/cli/githooks) checked into this repository. This folder contains hooks that should be executed by everyone who interacts with this source repository. For a documentation on how this works and how to get it [installed](https://github.com/gabyx/githooks#installation), check the project [README](https://github.com/gabyx/githooks/blob/main/README.md) in the [gabyx/githooks](https://github.com/gabyx/githooks) GitHub repository.
4+
5+
## Brief summary
6+
7+
The [directories or files](https://github.com/gabyx/githooks#layout-and-options) in this folder tell Git to execute certain scripts on various [trigger events](https://github.com/gabyx/githooks#supported-hooks), before or after a commit, on every checkout, before a push for example - assuming [Githooks](https://github.com/gabyx/githooks) is already [installed](https://github.com/gabyx/githooks#installation) and [run-wrappers are installed](https://github.com/gabyx/githooks#installing-or-removing-run-wrappers) for the repository. The directory or file names refer to these events, like `pre-commit`, `post-commit`, `post-checkout`, `pre-push`, etc. If they are folders, each file inside them is treated as a hook script and will be executed when Git runs the hooks as part of the command issued by the user. [Githooks](https://github.com/gabyx/githooks) comes with a [command line tool](https://github.com/gabyx/githooks/blob/main/docs/cli/git_hooks.md) tool, that allows you to manage its configuration and state with a `git hooks <cmd>` command. See the [documentation](https://github.com/gabyx/githooks/blob/main/docs/cli/git_hooks.md) or run `git hooks --help` for more information and available options.
8+
9+
### Is this safe?
10+
11+
[Githooks](https://github.com/gabyx/githooks) uses an [opt-in model](https://github.com/gabyx/githooks#trusting-hooks), where it will ask for confirmation whether new or changed hooks should be run or not (or disabled).
12+
13+
### How do I add a new hook script?
14+
15+
Either create a file with the [Git hook](https://github.com/gabyx/githooks#supported-hooks) name, or a directory (recommended) inside the `.githooks` folder, and place files with the individual steps that should be executed for that event inside. If the file is executable, it will be invoked directly, otherwise it is assumed to be a Shell script - unless this file matches one of the [ignore patterns](https://github.com/gabyx/githooks#ignoring-hooks-and-files) in the `.githooks` area.
16+
17+
### How can I see what hooks are active?
18+
19+
You can look at the `.githooks` folder to see the local hooks in the repository, though if you have shared hook repositories defined, those will live under the `~/.githooks/shared` folder.
20+
The [command line tool](https://github.com/gabyx/githooks/blob/main/docs/cli/git_hooks.md) can list out all of them for you with `git hooks list`, and you can use it to trust or ingoring hooks.
21+
22+
## More information
23+
24+
You can find more information about how this all works in the [README](https://github.com/gabyx/githooks/blob/main/README.md) of the [Githooks](https://github.com/gabyx/githooks) project repository.
25+
26+
If you find it useful, please show your support by starring the project in GitHub!

‎.githooks/trust-all

Whitespace-only changes.

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
.direnv

‎.prettierrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"semi": false,
5+
"singleQuote": false,
6+
"overrides": [
7+
{ "files": "*.md", "options": { "proseWrap": "always", "tabWidth": 2 } }
8+
]
9+
}

‎Cargo.lock

+386
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9+
# Good logging library.
10+
slog = "2.7.0"
11+
slog-term = "2.9.0"
12+
13+
# Popular serialization library.
14+
serde = { version = "1.0", features = ['derive']}

‎README.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# RDF Protect
2+
3+
A simple Rust CLI tool to protect values in RDF triples.
4+
5+
## Installation & Usage
6+
7+
TODO.
8+
9+
### Requirements
10+
11+
TODO.
12+
13+
## Development
14+
15+
TODO.

‎justfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
set positional-arguments
2+
set shell := ["bash", "-cue"]
3+
comp_dir := justfile_directory()
4+
root_dir := `git rev-parse --show-toplevel`
5+
6+
# General Variables:
7+
# You can chose either "podman" or "docker"
8+
container_mgr := "podman"
9+
10+
build *args:
11+
cd "{{root_dir}}" && cargo build "${@:1}"
12+
13+
watch:
14+
cd "{{root_dir}}" && cargo watch -x 'build'
15+
16+
format:
17+
cd "{{root_dir}}" && \
18+
{{container_mgr}} run -v "{{root_dir}}:/repo" -v "$(pwd):/workspace" -w "/workspace" \
19+
instrumentisto/rust:nightly-alpine cargo fmt -- --config-path /repo

‎nix/flake.lock

+102
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎nix/flake.nix

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
description = "rdf-protect";
3+
4+
nixConfig = {
5+
substituters = [
6+
# Add here some other mirror if needed.
7+
"https://cache.nixos.org/"
8+
];
9+
extra-substituters = [
10+
# Nix community's cache server
11+
"https://nix-community.cachix.org"
12+
];
13+
extra-trusted-public-keys = [
14+
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
15+
];
16+
};
17+
18+
inputs = {
19+
# Nixpkgs
20+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
21+
22+
# You can access packages and modules from different nixpkgs revs
23+
# at the same time. Here's an working example:
24+
nixpkgsStable.url = "github:nixos/nixpkgs/nixos-23.11";
25+
# Also see the 'stable-packages' overlay at 'overlays/default.nix'.
26+
27+
flake-utils.url = "github:numtide/flake-utils";
28+
29+
# The Rust overlay to include the latest toolchain.
30+
rust-overlay = {
31+
url = "github:oxalica/rust-overlay";
32+
inputs = {
33+
nixpkgs.follows = "nixpkgs";
34+
flake-utils.follows = "flake-utils";
35+
};
36+
};
37+
};
38+
39+
outputs = {
40+
self,
41+
nixpkgs,
42+
nixpkgsStable,
43+
flake-utils,
44+
rust-overlay,
45+
...
46+
} @ inputs:
47+
flake-utils.lib.eachDefaultSystem
48+
# Creates an attribute map `{ devShells.<system>.default = ...}`
49+
# by calling this function:
50+
(
51+
system: let
52+
overlays = [(import rust-overlay)];
53+
54+
# Import nixpkgs and load it into pkgs.
55+
pkgs = import nixpkgs {
56+
inherit system overlays;
57+
};
58+
59+
# Set the rust toolchain from the `rust-toolchain.toml`.
60+
rustToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ../rust-toolchain.toml;
61+
62+
# Things needed only at compile-time.
63+
nativeBuildInputsBasic = with pkgs; [
64+
rustToolchain
65+
cargo-watch
66+
67+
just
68+
parallel
69+
podman
70+
];
71+
72+
# Things needed only at compile-time.
73+
nativeBuildInputsDev = [];
74+
75+
# Things needed at runtime.
76+
buildInputs = [];
77+
in
78+
with pkgs; {
79+
devShells = {
80+
default = mkShell {
81+
inherit buildInputs;
82+
nativeBuildInputs = nativeBuildInputsBasic ++ nativeBuildInputsDev;
83+
};
84+
85+
ci = mkShell {
86+
inherit buildInputs;
87+
nativeBuildInputs = nativeBuildInputsBasic;
88+
};
89+
};
90+
}
91+
);
92+
}

‎rust-toolchain.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "nightly"
3+
components = [ "rustfmt", "rust-analyzer", "miri", "rust-docs", "clippy", "rust-src"]
4+
profile = "default"

‎rustfmt.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
edition = "2021"
2+
reorder_imports = true
3+
imports_granularity = "Crate"

0 commit comments

Comments
 (0)
Please sign in to comment.