Make table names more greppable
- Use lowercase table names when priting to terminal - Use `Creation Date` instead of `Created`, to make it distinct from the `Created` field type: changed
This commit is contained in:
		
							parent
							
								
									bdaec27caf
								
							
						
					
					
						commit
						06947fd63e
					
				| @ -74,7 +74,7 @@ mod tests { | |||||||
|       let have = env.out(); |       let have = env.out(); | ||||||
|       let want = "         Name  foo
 |       let want = "         Name  foo
 | ||||||
|       Comment  comment |       Comment  comment | ||||||
|      Created  1970-01-01 00:00:01 UTC | Creation Date  1970-01-01 00:00:01 UTC | ||||||
|    Created By  created by |    Created By  created by | ||||||
|        Source  source |        Source  source | ||||||
|     Info Hash  e12253978dc6d50db11d05747abcea1ad03b51c5 |     Info Hash  e12253978dc6d50db11d05747abcea1ad03b51c5 | ||||||
| @ -109,21 +109,21 @@ Content Size  20 bytes | |||||||
| 
 | 
 | ||||||
|       let have = env.out(); |       let have = env.out(); | ||||||
|       let want = "\ |       let want = "\ | ||||||
| Name\tfoo | name\tfoo | ||||||
| Comment\tcomment | comment\tcomment | ||||||
| Created\t1970-01-01 00:00:01 UTC | creation date\t1970-01-01 00:00:01 UTC | ||||||
| Created By\tcreated by | created by\tcreated by | ||||||
| Source\tsource | source\tsource | ||||||
| Info Hash\te12253978dc6d50db11d05747abcea1ad03b51c5 | info hash\te12253978dc6d50db11d05747abcea1ad03b51c5 | ||||||
| Torrent Size\t339 | torrent size\t339 | ||||||
| Content Size\t20 | content size\t20 | ||||||
| Private\tyes | private\tyes | ||||||
| Trackers\tannounce\tb\tc | trackers\tannounce\tb\tc | ||||||
| DHT Nodes\tx:12\t1.1.1.1:16\t[2001:db8:85a3::8a2e:370]:7334 | dht nodes\tx:12\t1.1.1.1:16\t[2001:db8:85a3::8a2e:370]:7334 | ||||||
| Piece Size\t16384 | piece size\t16384 | ||||||
| Piece Count\t2 | piece count\t2 | ||||||
| File Count\t1 | file count\t1 | ||||||
| Files\tfoo | files\tfoo | ||||||
| ";
 | ";
 | ||||||
| 
 | 
 | ||||||
|       assert_eq!(have, want); |       assert_eq!(have, want); | ||||||
| @ -172,7 +172,7 @@ Files\tfoo | |||||||
|       let have = env.out(); |       let have = env.out(); | ||||||
|       let want = "         Name  foo
 |       let want = "         Name  foo
 | ||||||
|       Comment  comment |       Comment  comment | ||||||
|      Created  1970-01-01 00:00:01 UTC | Creation Date  1970-01-01 00:00:01 UTC | ||||||
|    Created By  created by |    Created By  created by | ||||||
|        Source  source |        Source  source | ||||||
|     Info Hash  e12253978dc6d50db11d05747abcea1ad03b51c5 |     Info Hash  e12253978dc6d50db11d05747abcea1ad03b51c5 | ||||||
| @ -208,21 +208,21 @@ Content Size  20 bytes | |||||||
| 
 | 
 | ||||||
|       let have = env.out(); |       let have = env.out(); | ||||||
|       let want = "\ |       let want = "\ | ||||||
| Name\tfoo | name\tfoo | ||||||
| Comment\tcomment | comment\tcomment | ||||||
| Created\t1970-01-01 00:00:01 UTC | creation date\t1970-01-01 00:00:01 UTC | ||||||
| Created By\tcreated by | created by\tcreated by | ||||||
| Source\tsource | source\tsource | ||||||
| Info Hash\te12253978dc6d50db11d05747abcea1ad03b51c5 | info hash\te12253978dc6d50db11d05747abcea1ad03b51c5 | ||||||
| Torrent Size\t327 | torrent size\t327 | ||||||
| Content Size\t20 | content size\t20 | ||||||
| Private\tyes | private\tyes | ||||||
| Trackers\ta\tx\ty\tz | trackers\ta\tx\ty\tz | ||||||
| DHT Nodes\tx:12\t1.1.1.1:16\t[2001:db8:85a3::8a2e:370]:7334 | dht nodes\tx:12\t1.1.1.1:16\t[2001:db8:85a3::8a2e:370]:7334 | ||||||
| Piece Size\t16384 | piece size\t16384 | ||||||
| Piece Count\t2 | piece count\t2 | ||||||
| File Count\t1 | file count\t1 | ||||||
| Files\tfoo | files\tfoo | ||||||
| ";
 | ";
 | ||||||
| 
 | 
 | ||||||
|       assert_eq!(have, want); |       assert_eq!(have, want); | ||||||
| @ -271,7 +271,7 @@ Files\tfoo | |||||||
|       let have = env.out(); |       let have = env.out(); | ||||||
|       let want = "         Name  foo
 |       let want = "         Name  foo
 | ||||||
|       Comment  comment |       Comment  comment | ||||||
|      Created  1970-01-01 00:00:01 UTC | Creation Date  1970-01-01 00:00:01 UTC | ||||||
|    Created By  created by |    Created By  created by | ||||||
|        Source  source |        Source  source | ||||||
|     Info Hash  b9cd9cae5748518c99d00d8ae86c0162510be4d9 |     Info Hash  b9cd9cae5748518c99d00d8ae86c0162510be4d9 | ||||||
| @ -306,21 +306,21 @@ Content Size  20 bytes | |||||||
| 
 | 
 | ||||||
|       let have = env.out(); |       let have = env.out(); | ||||||
|       let want = "\ |       let want = "\ | ||||||
| Name\tfoo | name\tfoo | ||||||
| Comment\tcomment | comment\tcomment | ||||||
| Created\t1970-01-01 00:00:01 UTC | creation date\t1970-01-01 00:00:01 UTC | ||||||
| Created By\tcreated by | created by\tcreated by | ||||||
| Source\tsource | source\tsource | ||||||
| Info Hash\tb9cd9cae5748518c99d00d8ae86c0162510be4d9 | info hash\tb9cd9cae5748518c99d00d8ae86c0162510be4d9 | ||||||
| Torrent Size\t307 | torrent size\t307 | ||||||
| Content Size\t20 | content size\t20 | ||||||
| Private\tyes | private\tyes | ||||||
| Trackers\tb\tc\ta | trackers\tb\tc\ta | ||||||
| DHT Nodes\tx:12\t1.1.1.1:16\t[2001:db8:85a3::8a2e:370]:7334 | dht nodes\tx:12\t1.1.1.1:16\t[2001:db8:85a3::8a2e:370]:7334 | ||||||
| Piece Size\t16384 | piece size\t16384 | ||||||
| Piece Count\t1 | piece count\t1 | ||||||
| File Count\t1 | file count\t1 | ||||||
| Files\tfoo | files\tfoo | ||||||
| ";
 | ";
 | ||||||
| 
 | 
 | ||||||
|       assert_eq!(have, want); |       assert_eq!(have, want); | ||||||
|  | |||||||
							
								
								
									
										16
									
								
								src/table.rs
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/table.rs
									
									
									
									
									
								
							| @ -163,7 +163,7 @@ impl Table { | |||||||
| 
 | 
 | ||||||
|   pub(crate) fn write_tab_delimited(&self, out: &mut dyn Write) -> io::Result<()> { |   pub(crate) fn write_tab_delimited(&self, out: &mut dyn Write) -> io::Result<()> { | ||||||
|     for (name, value) in self.rows() { |     for (name, value) in self.rows() { | ||||||
|       write!(out, "{}\t", name)?; |       write!(out, "{}\t", name.to_lowercase())?; | ||||||
|       match value { |       match value { | ||||||
|         Value::List(list) => { |         Value::List(list) => { | ||||||
|           for (i, value) in list.iter().enumerate() { |           for (i, value) in list.iter().enumerate() { | ||||||
| @ -315,7 +315,7 @@ mod tests { | |||||||
|         FilePath::from_components(&["d"]), |         FilePath::from_components(&["d"]), | ||||||
|       ], |       ], | ||||||
|     ); |     ); | ||||||
|     tab_delimited(&table, "Files\tFoo/a/b\tFoo/a/c\tFoo/d\n"); |     tab_delimited(&table, "files\tFoo/a/b\tFoo/a/c\tFoo/d\n"); | ||||||
|     human_readable( |     human_readable( | ||||||
|       &table, |       &table, | ||||||
|       "\ |       "\ | ||||||
| @ -333,7 +333,7 @@ Files  Foo | |||||||
|     let mut table = Table::new(); |     let mut table = Table::new(); | ||||||
|     table.row("Foo", "bar"); |     table.row("Foo", "bar"); | ||||||
|     human_readable(&table, "Foo  bar\n"); |     human_readable(&table, "Foo  bar\n"); | ||||||
|     tab_delimited(&table, "Foo\tbar\n"); |     tab_delimited(&table, "foo\tbar\n"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   #[test] |   #[test] | ||||||
| @ -342,7 +342,7 @@ Files  Foo | |||||||
|     table.row("Foo", "bar"); |     table.row("Foo", "bar"); | ||||||
|     table.row("X", "y"); |     table.row("X", "y"); | ||||||
|     human_readable(&table, "Foo  bar\n  X  y\n"); |     human_readable(&table, "Foo  bar\n  X  y\n"); | ||||||
|     tab_delimited(&table, "Foo\tbar\nX\ty\n"); |     tab_delimited(&table, "foo\tbar\nx\ty\n"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   #[test] |   #[test] | ||||||
| @ -364,8 +364,8 @@ Something  a | |||||||
|     tab_delimited( |     tab_delimited( | ||||||
|       &table, |       &table, | ||||||
|       "\ |       "\ | ||||||
| Something\ta\tb\tc | something\ta\tb\tc | ||||||
| Other\tx\ty\tz | other\tx\ty\tz | ||||||
| ",
 | ",
 | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| @ -383,7 +383,7 @@ Foo  Bar: a | |||||||
|           y |           y | ||||||
| ",
 | ",
 | ||||||
|     ); |     ); | ||||||
|     tab_delimited(&table, "Foo\ta\tb\tx\ty\n"); |     tab_delimited(&table, "foo\ta\tb\tx\ty\n"); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   #[test] |   #[test] | ||||||
| @ -414,7 +414,7 @@ Second  Row:        the | |||||||
|     ); |     ); | ||||||
|     tab_delimited( |     tab_delimited( | ||||||
|       &table, |       &table, | ||||||
|       "First\tthe\tthing\tabout\tthat\nSecond\tthe\tthing\tabout\tthat\n", |       "first\tthe\tthing\tabout\tthat\nsecond\tthe\tthing\tabout\tthat\n", | ||||||
|     ); |     ); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -72,7 +72,7 @@ impl TorrentSummary { | |||||||
|     if let Some(creation_date) = self.metainfo.creation_date { |     if let Some(creation_date) = self.metainfo.creation_date { | ||||||
|       #[allow(clippy::as_conversions)] |       #[allow(clippy::as_conversions)] | ||||||
|       table.row( |       table.row( | ||||||
|         "Created", |         "Creation Date", | ||||||
|         Utc.timestamp( |         Utc.timestamp( | ||||||
|           creation_date |           creation_date | ||||||
|             .min(i64::max_value() as u64) |             .min(i64::max_value() as u64) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user