-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae998ae
commit 1bebaf3
Showing
4 changed files
with
16 additions
and
114 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,30 @@ | ||
use comfy_table::Table; | ||
|
||
use crate::book::{runtime::ExecutionFlavor, Book}; | ||
|
||
use super::ViewArgs; | ||
|
||
pub(crate) async fn view(args: ViewArgs) -> anyhow::Result<()> { | ||
let book = Book::from_path(args.path, args.filter)?; | ||
|
||
let mut table = Table::new(); | ||
|
||
table.set_header(vec!["page", "function", "context", "description"]); | ||
|
||
for (_, page) in book.pages { | ||
let mut first_page = true; | ||
println!("{} > [{}]", page.categories.join(" > "), page.name); | ||
|
||
for (function_name, function) in page.functions { | ||
if first_page { | ||
table.add_row(vec![ | ||
format!("{} > {}", page.categories.join(" > "), &page.name), | ||
function_name, | ||
ExecutionFlavor::for_function(&function)?.to_string(), | ||
function.description, | ||
]); | ||
first_page = false; | ||
} else { | ||
table.add_row(vec![ | ||
"".to_owned(), | ||
function_name, | ||
ExecutionFlavor::for_function(&function)?.to_string(), | ||
function.description, | ||
]); | ||
println!(" * {} : {}", function_name, function.description); | ||
println!( | ||
" running with: {}", | ||
ExecutionFlavor::for_function(&function)?.to_string() | ||
); | ||
println!(" parameters:"); | ||
for (parameter_name, parameter) in &function.parameters { | ||
println!( | ||
" {{${}}} : {}", | ||
parameter_name, parameter.description | ||
); | ||
} | ||
|
||
println!(); | ||
} | ||
} | ||
|
||
println!("\n{}", table); | ||
|
||
Ok(()) | ||
} |