File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
wp_rs_cli/src/bin/wp_rs_cli Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -413,14 +413,7 @@ fn parse_post_id(s: &str) -> Result<PostId, String> {
413
413
. map_err ( |e| format ! ( "Invalid post id '{s}': {e}" ) )
414
414
}
415
415
416
- async fn resolve_post_id ( client : & WpApiClient , args : & FetchPostArgs ) -> Result < PostId > {
417
- if let Some ( id) = args. post_id {
418
- return Ok ( id) ;
419
- }
420
- let Some ( post_url) = & args. url else {
421
- return Err ( anyhow ! ( "Either --post-id or --url must be provided" ) ) ;
422
- } ;
423
-
416
+ async fn resolve_post_id ( client : & WpApiClient , post_url : & str ) -> Result < PostId > {
424
417
// Strategy: retrieve by slug via posts list API when possible.
425
418
// For wp.com, the resolver requires site context; for wp.org, api_root is given.
426
419
// We'll try to parse the URL and extract a last path segment as potential slug.
@@ -456,7 +449,15 @@ async fn resolve_post_id(client: &WpApiClient, args: &FetchPostArgs) -> Result<P
456
449
async fn fetch_post_and_comments ( args : FetchPostArgs ) -> Result < ( ) > {
457
450
let client = build_api_client ( & args. auth , & args. url ) . await ?;
458
451
459
- let post_id = resolve_post_id ( & client, & args) . await ?;
452
+ let post_id = if let Some ( id) = args. post_id {
453
+ id
454
+ } else {
455
+ let post_url = args
456
+ . url
457
+ . as_ref ( )
458
+ . ok_or_else ( || anyhow ! ( "Either --post-id or --url must be provided" ) ) ?;
459
+ resolve_post_id ( & client, post_url. as_str ( ) ) . await ?
460
+ } ;
460
461
461
462
let post = client
462
463
. posts ( )
You can’t perform that action at this time.
0 commit comments