Skip to content

Commit 6516d0a

Browse files
author
Vsevolod
committed
added: help description
1 parent aea57b0 commit 6516d0a

File tree

5 files changed

+52
-30
lines changed

5 files changed

+52
-30
lines changed

module/move/gspread/src/actions/gspread_cell_get.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ mod private
3737
Some( values ) => Ok( values.get( 0 ).unwrap().get( 0 ).unwrap().clone() ),
3838
None => Ok( JsonValue::Null.clone() )
3939
}
40-
Err( error ) =>
41-
{
42-
Err( Error::ApiError( error ) )
43-
}
40+
Err( error ) => Err( Error::ApiError( error ) )
4441
}
4542

4643
}

module/move/gspread/src/actions/gspread_cell_set.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ mod private
4949
None => Err( Error::CellError( "Some problem with cell updating".to_string() ) )
5050
}
5151
}
52-
Err( error) =>
53-
{
54-
Err( Error::ApiError( error ) )
55-
}
52+
Err( error) => Err( Error::ApiError( error ) )
5653
}
5754

5855
}

module/move/gspread/src/commands/gspread.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,41 @@ mod private
2222
#[ derive( Debug, Parser ) ]
2323
pub struct CommonArgs
2424
{
25-
#[ arg( long ) ]
25+
#[ arg( long, help = "Full URL of Google Sheet.\n\
26+
It has to be inside of '' to avoid parse errors.\n\
27+
Example: 'https://docs.google.com/spreadsheets/d/your_spreadsheet_id/edit?gid=0#gid=0'" ) ]
2628
pub url : String,
2729

28-
#[ arg( long ) ]
30+
#[ arg( long, help = "Sheet name.\nExample: List1" ) ]
2931
pub tab : String
3032
}
3133

3234
#[ derive( Debug, Subcommand ) ]
3335
pub enum Command
3436
{
35-
37+
38+
/// Command to get header of a sheet. Header is a first raw.
3639
#[ command ( name = "header" ) ]
3740
Header
3841
(
3942
CommonArgs
4043
),
4144

45+
/// Command to get all raws of a sheet but not header.
4246
#[ command( name = "rows" ) ]
4347
Rows
4448
(
4549
CommonArgs
4650
),
4751

52+
/// Command to get or update a cell from a sheet.
4853
#[ command ( subcommand, name = "cell" ) ]
4954
Cell
5055
(
5156
gspread_cell::Commands
5257
),
5358

59+
/// Commands to set a new value to a cell or get a value from a cell.
5460
#[ command ( subcommand, name = "cells" ) ]
5561
Cells
5662
(

module/move/gspread/src/commands/gspread_cell.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,42 @@ mod private
1515
#[ derive( Debug, Subcommand ) ]
1616
pub enum Commands
1717
{
18+
/// Command to get a value from a sheet's cell
1819
#[ command( name = "get" ) ]
1920
Get
2021
{
21-
#[ arg( long ) ]
22+
#[ arg( long, help = "Full URL of Google Sheet.\n\
23+
It has to be inside of '' to avoid parse errors.\n\
24+
Example: 'https://docs.google.com/spreadsheets/d/your_spreadsheet_id/edit?gid=0#gid=0'" ) ]
2225
url : String,
2326

24-
#[ arg( long ) ]
27+
#[ arg( long, help = "Sheet name.\nExample: List1" ) ]
2528
tab : String,
2629

27-
#[ arg( long ) ]
28-
cel : String,
30+
#[ arg( long, help = "Cell id. You can set it in format:\n \
31+
- A1, where A is column name and 1 is row number\n\
32+
Example: --cell A4" ) ]
33+
cell : String,
2934
},
3035

36+
/// Command to set a new value to a sheet's cell.
3137
#[ command( name = "set" ) ]
3238
Set
3339
{
34-
#[ arg( long ) ]
40+
#[ arg( long, help = "Full URL of Google Sheet.\n\
41+
It has to be inside of '' to avoid parse errors.\n\
42+
Example: 'https://docs.google.com/spreadsheets/d/your_spreadsheet_id/edit?gid=0#gid=0'" ) ]
3543
url : String,
3644

37-
#[ arg( long ) ]
45+
#[ arg( long, help = "Sheet name.\nExample: List1" ) ]
3846
tab : String,
3947

40-
#[ arg( long ) ]
41-
cel : String,
48+
#[ arg( long, help = "Cell id. You can set it in format:\n \
49+
- A1, where A is column name and 1 is row number\n\
50+
Example: --cell A4" ) ]
51+
cell : String,
4252

43-
#[ arg( long ) ]
53+
#[ arg( long, help = "Value you want to set. It can be written on any language.\nExample: --val hello" ) ]
4454
val : String
4555
}
4656
}
@@ -53,7 +63,7 @@ mod private
5363
{
5464
match commands
5565
{
56-
Commands::Get { url, tab, cel } =>
66+
Commands::Get { url, tab, cell } =>
5767
{
5868
let spreadsheet_id = match get_spreadsheet_id_from_url( url.as_str() )
5969
{
@@ -70,16 +80,16 @@ mod private
7080
hub,
7181
spreadsheet_id,
7282
tab.as_str(),
73-
cel.as_str()
83+
cell.as_str()
7484
)
7585
.await
7686
{
7787
Ok( value ) => println!( "Value: {}", value ),
78-
Err( error ) => println!( "Error: {}", error ),
88+
Err( error ) => println!( "Error:\n{}", error ),
7989
}
8090
},
8191

82-
Commands::Set { url, tab, cel, val } =>
92+
Commands::Set { url, tab, cell, val } =>
8393
{
8494
let spreadsheet_id = match get_spreadsheet_id_from_url( url.as_str() )
8595
{
@@ -96,7 +106,7 @@ mod private
96106
hub,
97107
spreadsheet_id,
98108
tab.as_str(),
99-
cel.as_str(),
109+
cell.as_str(),
100110
val.as_str()
101111
)
102112
.await

module/move/gspread/src/commands/gspread_cells.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,31 @@ mod private
1313
#[ derive( Debug, Subcommand ) ]
1414
pub enum Commands
1515
{
16+
/// Command to set values range to a google sheet
1617
#[ command( name = "set" ) ]
1718
Set
1819
{
19-
#[ arg( long ) ]
20+
#[ arg( long, help = "Identifier of a row. Available identifiers: id (row's unique identifier).\n\
21+
Example: --select_row_by_key \"id\"" ) ]
2022
select_row_by_key : String,
21-
22-
#[ arg( long ) ]
23+
24+
#[ arg( long, help = "Value range. It must contain select_row_by_key.
25+
The key is a column name (not a header name, but a column name, which can only contain Latin letters).
26+
Every key and value must be a string.
27+
Depending on the shell, different handling might be required.\n\
28+
Examples:\n\
29+
1. --json '\"id\": \"3\", \"A\": \"1\", \"B\": \"2\"'\n\
30+
2. --json \"\"id\": \"3\", \"A\": \"1\", \"B\": \"2\"\"\n\
31+
3. --json '\\\"id\\\": \\\"3\\\", \\\"A\\\": \\\"1\\\", \\\"B\\\": \\\"2\\\"'\n\
32+
4. --json \"\\\"id\\\": \\\"3\\\", \\\"A\\\": \\\"1\\\", \\\"B\\\": \\\"2\\\"\" " ) ]
2333
json : String,
2434

25-
#[ arg( long ) ]
35+
#[ arg( long, help = "Full URL of Google Sheet.\n\
36+
It has to be inside of '' to avoid parse errors.\n\
37+
Example: 'https://docs.google.com/spreadsheets/d/your_spreadsheet_id/edit?gid=0#gid=0'" ) ]
2638
url : String,
2739

28-
#[ arg( long ) ]
40+
#[ arg( long, help = "Sheet name.\nExample: List1" ) ]
2941
tab : String
3042
}
3143

0 commit comments

Comments
 (0)