File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ use std:: process:: { Command , Stdio } ;
2+ pub ( crate ) fn open_html ( file_path : & str ) {
3+ if cfg ! ( target_os = "windows" ) {
4+ let _ = Command :: new ( "cmd" )
5+ . args ( & [ "/C" , & format ! ( "start {}" , file_path) ] )
6+ . stdout ( Stdio :: null ( ) )
7+ . stderr ( Stdio :: null ( ) )
8+ . spawn ( ) ;
9+ } else if cfg ! ( target_os = "macos" ) {
10+ let _ = Command :: new ( "open" )
11+ . arg ( file_path)
12+ . stdout ( Stdio :: null ( ) )
13+ . stderr ( Stdio :: null ( ) )
14+ . spawn ( ) ;
15+ } else if cfg ! ( target_os = "linux" ) {
16+ let _ = Command :: new ( "xdg-open" )
17+ . arg ( file_path)
18+ . stdout ( Stdio :: null ( ) )
19+ . stderr ( Stdio :: null ( ) )
20+ . spawn ( ) ;
21+ } else {
22+ eprintln ! ( "HTML Renderer is not supported on this platform." ) ;
23+ } ;
24+ }
Original file line number Diff line number Diff line change 11pub mod execution;
22mod helpers;
3+ pub mod html_opener;
34pub mod leetcode;
45pub mod submission;
56pub mod user;
Original file line number Diff line number Diff line change 11use crate :: file_parser:: codefile:: CodeFile ;
2+ use crate :: leetcode_api:: html_opener:: open_html;
23use crate :: utils:: { execute_testcases, submit} ;
34use clap:: { Parser , Subcommand } ;
45use colored:: Colorize ;
@@ -120,6 +121,7 @@ fn main() -> ExitCode {
120121 let filename = "daily_challenge.html" ;
121122 if let Ok ( _) = std:: fs:: write ( filename, question. content ) {
122123 println ! ( "Saved question as HTML to {}" , filename. cyan( ) ) ;
124+ open_html ( filename) ;
123125 ExitCode :: SUCCESS
124126 } else {
125127 eprintln ! ( "Error saving question as HTML" ) ;
@@ -153,6 +155,7 @@ fn main() -> ExitCode {
153155 // save to filename
154156 if let Ok ( _) = std:: fs:: write ( & filename, question. content ) {
155157 println ! ( "Saved question as HTML to {}" , filename. cyan( ) ) ;
158+ open_html ( & filename) ;
156159 ExitCode :: SUCCESS
157160 } else {
158161 eprintln ! ( "Error saving question as HTML" ) ;
You can’t perform that action at this time.
0 commit comments