Skip to content

A command-line tool to convert handwritten notes to markdown files

feat: added notion to the onboarding flow

Tejas Raskarf9b671c28593
diff --git a/src/config.rs b/src/config.rs
index 41a9ff2..4e8efdc 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -10,6 +10,13 @@ pub struct Config {
pub ollama: Option<OllamaConfig>,
pub claude: Option<ClaudeConfig>,
pub openai: Option<OpenAIConfig>,
+ pub notion: Option<NotionConfig>,
+}
+
+#[derive(Serialize, Deserialize, Debug, Default)]
+pub struct NotionConfig {
+ pub api_key: String,
+ pub database_id: String,
}
#[derive(Serialize, Deserialize, Debug, Default)]
diff --git a/src/main.rs b/src/main.rs
index a256794..4c7fe3b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,6 +12,7 @@ use clap::Parser;
use cli::{Cli, Commands};
use colored::*;
use config::{ClaudeConfig, Config, GeminiConfig, OllamaConfig};
+use dialoguer::Confirm;
use dialoguer::Input;
use dialoguer::Select;
use dialoguer::{Password, theme::ColorfulTheme};
@@ -23,6 +24,7 @@ use crate::clients::claude_client::ClaudeClient;
use crate::clients::gemini_client::GeminiClient;
use crate::clients::ollama_client::OllamaClient;
use crate::clients::openai_client::OpenAIClient;
+use crate::config::NotionConfig;
use crate::config::OpenAIConfig;
use std::path::Path;
use ui::{ascii_art, print_clean_config};
@@ -268,6 +270,29 @@ async fn run() -> Result<(), NotedError> {
}
_ => unreachable!(),
}
+
+ // notion
+ let is_notion = Confirm::with_theme(&ColorfulTheme::default())
+ .with_prompt("Do you want to configure Notion to save your notes there?")
+ .default(false)
+ .interact()?;
+
+ if is_notion {
+ let api_key = Password::with_theme(&ColorfulTheme::default())
+ .with_prompt("Enter your Notion API key: ")
+ .interact()?;
+ let database_id = Input::with_theme(&ColorfulTheme::default())
+ .with_prompt("Enter your Notion Database ID: ")
+ .default("".to_string())
+ .interact()?;
+
+ let mut config = Config::load()?;
+ config.notion = Some(NotionConfig {
+ api_key,
+ database_id,
+ });
+ config.save()?;
+ }
println!(
"{}",
"You can now run 'notedmd convert <file>' to convert your files.".cyan()
diff --git a/src/ui.rs b/src/ui.rs
index fbdeac6..d8ba8d2 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -76,4 +76,16 @@ pub fn print_clean_config(config: Config) {
} else {
println!(" (Not Configured)");
}
+
+ println!("{}", "Notion".bold());
+ if let Some(notion_config) = config.notion {
+ let api_key = format!(
+ "{:.3}***************** (hidden for security)",
+ notion_config.api_key
+ );
+ println!(" API Key: {}", api_key);
+ println!(" Database ID: {}", notion_config.database_id);
+ } else {
+ println!(" (Not Configured)");
+ }
}