Skip to content

Added create command to rnote-cli#1663

Merged
flxzt merged 8 commits intoflxzt:mainfrom
DarshPareek:cli_create
Mar 12, 2026
Merged

Added create command to rnote-cli#1663
flxzt merged 8 commits intoflxzt:mainfrom
DarshPareek:cli_create

Conversation

@DarshPareek
Copy link
Copy Markdown
Contributor

@DarshPareek DarshPareek commented Feb 18, 2026

This PR adds the functionality of doing two things with the rnote-cli command:

  1. Create a new already saved file on disc with name passed from cli: rnote-cli create <new_note_name>
  2. Create a new already saved file on disc but with a template both passed from cli: rnote-cli create <new_note_name> --template-file <rnote_template_name>

the template must be rnote file too.

I have added a new create crate to rnote-cli crate.
I have added the respective functions to create file with template etc.

This PR tries to solve #1399 in a different way.

@flxzt
Copy link
Copy Markdown
Owner

flxzt commented Mar 7, 2026

What's the use of the template argument? I can see creating a new file from scratch only using the CLI being a valid use-case, but not for the template.

@DarshPareek
Copy link
Copy Markdown
Contributor Author

Actually there is, people use different templates for different types of notes, I want to make a plugin to add the functionality to create .rnote files directly from obsidian or similar applications which will use this templates to so people dont have to setup everything. If you are interested you can look at the obsidian-xournalpp plugin

@flxzt
Copy link
Copy Markdown
Owner

flxzt commented Mar 7, 2026

yes, but why don't you just copy the template file?

@DarshPareek
Copy link
Copy Markdown
Contributor Author

I guess that's what i am doing internally, I am copying bytes of template file to new file. Also at the time of making this PR i didn't knew we had a copy command so my bad.

@flxzt
Copy link
Copy Markdown
Owner

flxzt commented Mar 7, 2026

if you remove the template part I would merge the create command

@DarshPareek
Copy link
Copy Markdown
Contributor Author

okay, I will edit that part out

@DarshPareek
Copy link
Copy Markdown
Contributor Author

I removed the template argument from the create command

Comment thread crates/rnote-cli/src/cli.rs Outdated
Comment thread crates/rnote-cli/src/cli.rs Outdated
/// Output path of the thumbnail
output: PathBuf,
},
/// Make a rnote file from the cli
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Rewrite to Create a new rnote file.

Comment thread crates/rnote-cli/src/cli.rs
Comment thread crates/rnote-cli/src/create.rs Outdated
@@ -0,0 +1,36 @@
// Creates
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This comment should be // Imports

Comment thread crates/rnote-cli/src/create.rs Outdated

// Pass the Option through to the inner function
if let Err(e) = create_new_file(&mut engine, input_file).await {
println!("Cannot Create a file: {:?}", e);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

return the error instead of printing it.

Comment thread crates/rnote-cli/src/create.rs Outdated
println!("Cannot Create a file: {:?}", e);
return Err(e);
} else {
println!("File Created Successfully");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Also here.

Comment thread crates/rnote-cli/src/create.rs Outdated
@DarshPareek
Copy link
Copy Markdown
Contributor Author

I removed the engine config loading and also the print statements.

@flxzt
Copy link
Copy Markdown
Owner

flxzt commented Mar 12, 2026

Thanks, did some minor adjustments and cleanup.

@flxzt flxzt merged commit 60a0dba into flxzt:main Mar 12, 2026
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.

2 participants