Skip to content

Commit

Permalink
update directory writer
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Nov 3, 2023
1 parent ec165b5 commit a30b34d
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions .github/workflows/directory.jule
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use std::fs::{DirEntry, FsError, OFlag, File, Directory}

static mut TABLE: str = ""

static PACKAGES: [...]str = [
"./math",
"./search",
"./sort",
"./string",
static IGNORE_PACKAGES: [...]str = [
".",
"..",
".github",
".git",
]

fn workflow_failed(message: str) {
Expand Down Expand Up @@ -91,7 +91,7 @@ fn make_name(mut s: str): str {
fn append_package(package: str) {
let mut dirents = Directory.read(package) else {
workflow_failed("package did not readed: " + package)
ret // Avoid derror.
ret // Avoid error.
}

let package_table_name = make_name(package)
Expand Down Expand Up @@ -121,16 +121,32 @@ fn append_package(package: str) {

fn create_directory_md() {
const MD_PATH = "./DIRECTORY.md"
File.write(MD_PATH, ([]byte)(TABLE), 0o666) else {
File.write(MD_PATH, []byte(TABLE), 0o660) else {
workflow_failed("a problem occurs when creating " + MD_PATH)
}
}

fn main() {
write_line("# Table of Contents")

for _, package in PACKAGES {
append_package(package)
let mut dirents = Directory.read(".") else {
workflow_failed("directory did not readed")
ret // Avoid error.
}

sort_dirents(dirents)

dirent:
for _, d in dirents {
for _, ip in IGNORE_PACKAGES {
if ip == d.name {
continue dirent
}
}

if d.stat.is_dir() {
append_package(d.name)
}
}

create_directory_md()
Expand Down

0 comments on commit a30b34d

Please sign in to comment.