@@ -7,7 +7,7 @@ use globwalk::FileType;
77use odoo_lsp:: config:: { CompletionsConfig , Config , ModuleConfig , ReferencesConfig , SymbolsConfig } ;
88use odoo_lsp:: index:: { _R, Index } ;
99use odoo_lsp:: utils:: strict_canonicalize;
10- use odoo_lsp:: { GIT_VERSION , GITVER , NAME , VERSION , errloc, format_loc, loc} ;
10+ use odoo_lsp:: { GIT_VERSION , GITVER , NAME , VERSION , errloc, format_loc, loc, ok } ;
1111use self_update:: { Status , backends:: github} ;
1212use serde_json:: Value ;
1313use tracing:: { debug, warn} ;
@@ -122,25 +122,19 @@ pub fn parse_args<'r>(mut args: &[&'r str]) -> Args<'r> {
122122}
123123
124124fn print_usage ( ) -> anyhow:: Result < ( ) > {
125- #[ cfg( unix) ]
126- if let Ok ( stat) = std:: process:: Command :: new ( "man" )
127- . arg ( "-h" )
128- . stdout ( std:: process:: Stdio :: null ( ) )
129- . stderr ( std:: process:: Stdio :: null ( ) )
130- . status ( )
131- && stat. success ( )
125+ use std:: io:: Write ;
126+ use std:: process:: { Command , Stdio } ;
127+
128+ const MANPAGE : & str = include_str ! ( "../contrib/debian/usr/share/man/man1/odoo-lsp.1" ) ;
129+
130+ let mut man = Command :: new ( "man" ) . args ( [ "-l" , "-" ] ) . stdin ( Stdio :: piped ( ) ) . spawn ( ) ?;
132131 {
133- use std:: io:: Write ;
134- const MANPAGE : & str = include_str ! ( "../contrib/debian/usr/share/man/man1/odoo-lsp.1" ) ;
135-
136- let manpage = tempfile:: NamedTempFile :: new ( ) ?;
137- let mut file = std:: fs:: File :: options ( ) . write ( true ) . open ( manpage. path ( ) ) ?;
138- file. write_all ( MANPAGE . as_bytes ( ) ) ?;
139- std:: process:: Command :: new ( "man" ) . arg ( manpage. path ( ) ) . status ( ) ?;
140- return Ok ( ( ) ) ;
132+ let mut stdin = ok ! ( man. stdin. take( ) , "failed to open man stdin" ) ;
133+ stdin. write_all ( MANPAGE . as_bytes ( ) ) ?;
141134 }
135+ man. wait ( ) ?;
142136
143- Err ( anyhow :: anyhow! ( "no manpage support" ) )
137+ Ok ( ( ) )
144138}
145139
146140/// Returns true if a CLI handler has been invoked.
0 commit comments