File tree Expand file tree Collapse file tree 2 files changed +20
-9
lines changed
Expand file tree Collapse file tree 2 files changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -49,14 +49,13 @@ fn print_completion<G: Generator>(gen: G, cmd: &mut Command) {
4949 generate ( gen, cmd, cmd. get_name ( ) . to_string ( ) , & mut io:: stdout ( ) )
5050}
5151
52- /// Reads from stdin and uploads to a pastebin backend
53- pub fn pastry ( ) -> Result < String > {
52+ pub fn run ( ) -> Result < ( ) > {
5453 let args = Args :: parse ( ) ;
5554
5655 match & args. command {
5756 Some ( Commands :: Completion { shell } ) => {
5857 print_completion ( * shell, & mut Args :: command ( ) ) ;
59- return Ok ( "" . to_string ( ) ) ;
58+ return Ok ( ( ) ) ;
6059 }
6160 None => { }
6261 }
@@ -75,5 +74,11 @@ pub fn pastry() -> Result<String> {
7574 } ) ,
7675 } ;
7776 let url = endpoint_api. upload ( result) ;
78- url
77+ match url {
78+ Ok ( url) => {
79+ print ! ( "{}" , url) ;
80+ Ok ( ( ) )
81+ }
82+ Err ( err) => Err ( err) ,
83+ }
7984}
Original file line number Diff line number Diff line change 1- use pastry as lib ;
1+ use std :: process :: ExitCode ;
22
3- use anyhow :: Result ;
3+ use pastry ;
44
5- fn main ( ) -> Result < ( ) > {
6- print ! ( "{}" , lib:: pastry( ) ?) ;
7- Ok ( ( ) )
5+ fn main ( ) -> ExitCode {
6+ let result = pastry:: run ( ) ;
7+ match result {
8+ Ok ( _) => ExitCode :: SUCCESS ,
9+ Err ( err) => {
10+ eprintln ! ( "{}" , err) ;
11+ ExitCode :: FAILURE
12+ }
13+ }
814}
You can’t perform that action at this time.
0 commit comments