-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add post CRUD commands #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/main.zig
Outdated
| const PostListFormat = enum { | ||
| table, | ||
| json, | ||
| csv, | ||
| }; |
There was a problem hiding this comment.
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; | ||
| } | ||
|
|
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
552a1f7 to
89201ec
Compare
Summary
gesttalt postCRUD subcommands with env var support and editor openingDetailed Design
gesttalt postis a new top-level command with subcommands:create,list,read,update,delete.GESTTALT_env var. Flags take precedence over env vars.create:-,_).--date YYYY-MM-DD.content/blog/YYYY/MM/DD/<slug>.mdwith TOML frontmatter and opens$EDITORif set.list:core/posts.zigloader.table(TSV),json, orcsvwith date/slug/title/tags, sorted newest-first.read:update:--tagsreplaces,--add-tagsappends,--remove-tagsprunes.delete:--force(or env var) and deletes the file.DD,MM, andYYYYdirectories.Testing
Closes #13