Skip to content

Commit 087f4fd

Browse files
committed
Make body of creation optional
1 parent 0aaaf3f commit 087f4fd

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,16 @@ mks pages my-project --limit 20 --link
117117
Create a new page with content:
118118

119119
```
120-
mks create <page> <body> [options]
120+
mks create <page> [options]
121121
```
122122

123123
Options:
124+
- `--body` or `-b`: Specify a body
124125
- `--url` or `-u`: Display the API URL instead of creating the page
125126

126127
Example:
127128
```
128-
mks create "My New Page" "This is the content of my new page."
129+
mks create my-project/my-page --body "This is the content of my new page."
129130
```
130131

131132
### Page

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ enum SubCommands {
6969
Create {
7070
/// Page name
7171
page: String,
72+
#[clap(short, long)]
7273
/// Body of page
73-
body: String,
74+
body: Option<String>,
7475
#[clap(short, long)]
7576
/// Get URL of API
7677
url: bool,

src/makesense/commands/create.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pub async fn create(page: String, body: String, url: bool) -> Result<(), Box<dyn std::error::Error>> {
2-
let endpoint = format!("https://scrapbox.io/{}?body={}", page, body);
1+
pub async fn create(page: String, body: Option<String>, url: bool) -> Result<(), Box<dyn std::error::Error>> {
2+
let endpoint = format!("https://scrapbox.io/{}?body={}", page, body.unwrap_or("".to_string()));
33
if url {
44
println!("{}", endpoint);
55
return Ok(());

0 commit comments

Comments
 (0)