Skip to content

Commit cdfb5ad

Browse files
committed
core xtask functionality
1 parent 6a7481c commit cdfb5ad

File tree

7 files changed

+129
-1
lines changed

7 files changed

+129
-1
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[alias]
2+
xtask = "run --package xtask --"

.github/workflows/xtask.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: XTasks
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "xtask"
7+
- "Cargo.toml"
8+
- "Cargo.lock"
9+
- ".cargo"
10+
- "core/tabs"
11+
push:
12+
paths:
13+
- "xtask"
14+
- "Cargo.toml"
15+
- "Cargo.lock"
16+
- ".cargo"
17+
- "core/tabs"
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
22+
jobs:
23+
docgen:
24+
name: DocGen
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout sources
29+
uses: actions/checkout@v4
30+
31+
- name: Install Rust
32+
uses: dtolnay/rust-toolchain@stable
33+
34+
- name: Cache Cargo registry
35+
uses: actions/cache@v4
36+
with:
37+
path: ~/.cargo/registry
38+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
39+
restore-keys: ${{ runner.os }}-cargo-registry-
40+
41+
- name: Cache Cargo index
42+
uses: actions/cache@v4
43+
with:
44+
path: ~/.cargo/git
45+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
46+
restore-keys: ${{ runner.os }}-cargo-index-
47+
48+
- name: Run cargo xtask docgen
49+
run: cargo xtask docgen
50+
51+
- name: Check uncommitted documentation changes
52+
run: |
53+
git diff
54+
git diff-files --quiet \
55+
|| (echo "Run 'cargo xtask docgen' and push the changes" \
56+
&& exit 1)

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[workspace.package]
22
license = "MIT"
33
version = "24.9.28"
4+
edition = "2021"
45

56
[workspace.dependencies]
67
ego-tree = "0.6.2"
78

89
[workspace]
9-
members = ["tui", "core"]
10+
members = ["tui", "core", "xtask"]
1011
resolver = "2"
1112

1213
[patch.crates-io]

xtask/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "xtask"
3+
version.workspace = true
4+
license.workspace = true
5+
edition.workspace = true
6+
7+
[dependencies]
8+
linutil_core = { path = "../core" }

xtask/src/docgen.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::DynError;
2+
use linutil_core::{ListNode, Tab};
3+
4+
pub fn ttest() {
5+
let ok = linutil_core::get_tabs(false).1;
6+
7+
for tab in ok {
8+
#[cfg(debug_assertions)]
9+
println!("Tab: {}", tab.name);
10+
11+
for entry in tab.tree {
12+
#[cfg(debug_assertions)]
13+
println!(" Entry: {}", entry.name);
14+
println!(" Description: {}", entry.description);
15+
}
16+
}
17+
}

xtask/src/main.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
mod docgen;
2+
3+
use std::{env, error::Error};
4+
5+
type DynError = Box<dyn Error>;
6+
7+
pub mod tasks {
8+
use crate::{docgen::ttest, DynError};
9+
10+
pub fn docgen() -> Result<(), DynError> {
11+
ttest();
12+
Ok(())
13+
}
14+
15+
pub fn print_help() {
16+
println!(
17+
"
18+
Usage: `cargo xtask <task>`
19+
20+
Tasks:
21+
docgen: Generate Markdown files.
22+
"
23+
);
24+
}
25+
}
26+
27+
fn main() -> Result<(), DynError> {
28+
let task = env::args().nth(1);
29+
match task {
30+
None => tasks::print_help(),
31+
Some(t) => match t.as_str() {
32+
"docgen" => tasks::docgen()?,
33+
invalid => return Err(format!("Invalid task: {}", invalid).into()),
34+
},
35+
};
36+
Ok(())
37+
}

0 commit comments

Comments
 (0)