@@ -11,6 +11,7 @@ use std::io::Seek;
1111use std:: io:: SeekFrom ;
1212use std:: time:: Duration ;
1313
14+ use annotate_snippets:: Level ;
1415use anyhow:: Context as _;
1516use anyhow:: bail;
1617use cargo_credential:: Operation ;
@@ -108,12 +109,16 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
108109 if allow_unpublishable {
109110 let n = unpublishable. len ( ) ;
110111 let plural = if n == 1 { "" } else { "s" } ;
111- ws. gctx ( ) . shell ( ) . warn ( format_args ! (
112- "nothing to publish, but found {n} unpublishable package{plural}"
113- ) ) ?;
114- ws. gctx ( ) . shell ( ) . note ( format_args ! (
115- "to publish packages, set `package.publish` to `true` or a non-empty list"
116- ) ) ?;
112+ ws. gctx ( ) . shell ( ) . print_report (
113+ & [ Level :: WARNING
114+ . secondary_title ( format ! (
115+ "nothing to publish, but found {n} unpublishable package{plural}"
116+ ) )
117+ . element ( Level :: HELP . message (
118+ "to publish packages, set `package.publish` to `true` or a non-empty list" ,
119+ ) ) ] ,
120+ false ,
121+ ) ?;
117122 return Ok ( ( ) ) ;
118123 } else {
119124 unreachable ! ( "must have at least one publishable package" ) ;
@@ -323,18 +328,23 @@ pub fn publish(ws: &Workspace<'_>, opts: &PublishOpts<'_>) -> CargoResult<()> {
323328 ) ?;
324329 } else {
325330 let short_pkg_descriptions = package_list ( to_confirm. iter ( ) . copied ( ) , "or" ) ;
326- opts. gctx . shell ( ) . warn ( format ! (
327- "timed out waiting for {short_pkg_descriptions} to be available in {source_description}" ,
328- ) ) ?;
329- opts. gctx . shell ( ) . note ( format ! (
330- "the registry may have a backlog that is delaying making the \
331- {crate} available. The {crate} should be available soon.",
332- crate = if to_confirm. len( ) == 1 {
333- "crate"
334- } else {
335- "crates"
336- }
337- ) ) ?;
331+ let krate = if to_confirm. len ( ) == 1 {
332+ "crate"
333+ } else {
334+ "crates"
335+ } ;
336+ opts. gctx . shell ( ) . print_report (
337+ & [ Level :: WARNING
338+ . secondary_title ( format ! (
339+ "timed out waiting for {short_pkg_descriptions} \
340+ to be available in {source_description}",
341+ ) )
342+ . element ( Level :: NOTE . message ( format ! (
343+ "the registry may have a backlog that is delaying making the \
344+ {krate} available. The {krate} should be available soon.",
345+ ) ) ) ] ,
346+ false ,
347+ ) ?;
338348 }
339349 confirmed
340350 } else {
@@ -676,25 +686,38 @@ fn transmit(
676686
677687 if !warnings. invalid_categories . is_empty ( ) {
678688 let msg = format ! (
679- "the following are not valid category slugs and were \
680- ignored: {}. Please see https://crates.io/category_slugs \
681- for the list of all category slugs. \
682- ",
689+ "the following are not valid category slugs and were ignored: {}" ,
683690 warnings. invalid_categories. join( ", " )
684691 ) ;
685- gctx. shell ( ) . warn ( & msg) ?;
692+ gctx. shell ( ) . print_report (
693+ & [ Level :: WARNING
694+ . secondary_title ( msg)
695+ . element ( Level :: HELP . message (
696+ "please see <https://crates.io/category_slugs> for the list of all category slugs" ,
697+ ) ) ] ,
698+ false ,
699+ ) ?;
686700 }
687701
688702 if !warnings. invalid_badges . is_empty ( ) {
689703 let msg = format ! (
690- "the following are not valid badges and were ignored: {}. \
691- Either the badge type specified is unknown or a required \
692- attribute is missing. Please see \
693- https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata \
694- for valid badge types and their required attributes.",
704+ "the following are not valid badges and were ignored: {}" ,
695705 warnings. invalid_badges. join( ", " )
696706 ) ;
697- gctx. shell ( ) . warn ( & msg) ?;
707+ gctx. shell ( ) . print_report (
708+ & [ Level :: WARNING . secondary_title ( msg) . elements ( [
709+ Level :: NOTE . message (
710+ "either the badge type specified is unknown or a required \
711+ attribute is missing",
712+ ) ,
713+ Level :: HELP . message (
714+ "please see \
715+ <https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata> \
716+ for valid badge types and their required attributes",
717+ ) ,
718+ ] ) ] ,
719+ false ,
720+ ) ?;
698721 }
699722
700723 if !warnings. other . is_empty ( ) {
0 commit comments