Skip to content

Conversation

@pepicrft
Copy link
Owner

@pepicrft pepicrft commented Jan 2, 2026

Summary

  • add gesttalt post CRUD subcommands with env var support and editor opening
  • implement frontmatter serialization/helpers for post create/update
  • document post CLI commands and env vars in SPEC

Detailed Design

  • gesttalt post is a new top-level command with subcommands: create, list, read, update, delete.
  • All options are parsed via clap; any option that takes a value is also backed by a GESTTALT_ env var. Flags take precedence over env vars.
  • create:
    • Validates slug (letters, numbers, -, _).
    • Date defaults to today (UTC) or uses --date YYYY-MM-DD.
    • Writes content/blog/YYYY/MM/DD/<slug>.md with TOML frontmatter and opens $EDITOR if set.
  • list:
    • Loads posts via existing core/posts.zig loader.
    • Outputs table (TSV), json, or csv with date/slug/title/tags, sorted newest-first.
  • read:
    • Finds post by slug across all dates and prints full markdown or JSON payload (frontmatter + content).
  • update:
    • Finds post by slug, rewrites frontmatter fields, preserves markdown content.
    • --tags replaces, --add-tags appends, --remove-tags prunes.
  • delete:
    • Confirms unless --force (or env var) and deletes the file.
    • Attempts to prune empty DD, MM, and YYYY directories.

Testing

  • not run (not requested)

Closes #13

src/main.zig Outdated
Comment on lines 89 to 102
const PostListFormat = enum {
table,
json,
csv,
};
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why these formats? You should support json, and toon for agents.

src/main.zig Outdated
defer allocator.free(env_port);
return std.fmt.parseInt(u16, env_port, 10) catch 3000;
}

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of logic in this file.

src/main.zig Outdated
return std.process.getEnvVarOwned(allocator, env_name) catch null;
}

fn getBoolEnv(allocator: std.mem.Allocator, env_name: []const u8) bool {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a library that we can use for these things.

src/main.zig Outdated
Logger.info(" cd {s}", .{name});
Logger.info(" gesttalt dev", .{});
},
.post => {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main.zig is a monolith file and shouldn't be like that. Rethink the architecture.

src/main.zig Outdated
}

fn printPostHelp() void {
std.debug.print(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect you to use a library that allows the declaration of the CLI interface and can generate the help menu too.

src/main.zig Outdated
return;
};

const force = delete_res.args.force != 0 or getBoolEnv(allocator, "GESTTALT_POST_FORCE");
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract the posts crud into its own module and ensure things are tested.

@pepicrft pepicrft merged commit 02017cf into main Jan 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CRUD commands for posts

2 participants