@@ -92,12 +92,23 @@ fn main() -> Result<(), Box<dyn Error>> {
9292 team_prompt = team_prompt. with_autocomplete ( TeamNames :: from_teams ( teams) ) ;
9393 }
9494
95- let team = team_prompt. prompt ( ) ?;
95+ let mut team = team_prompt. prompt ( ) ?;
9696
9797 let url = if let Some ( url) = team_data
9898 . as_ref ( )
9999 . and_then ( |teams| find_team_url ( teams, & team) )
100100 {
101+ // At this point, a canonical team has been selected, and we have a URL for it.
102+ // This should be the common "happy path".
103+ // However, displaying the canonical team name in the blog heading is not ideal, usually
104+ // users will want to modify it slightly, so give them the option.
105+ let normalized = normalize_team_name ( team) ;
106+ let team_label = format ! ( "the {normalized} team" ) ;
107+ let team_label = Text :: new ( "What text should be used after 'on behalf of'?" )
108+ . with_initial_value ( & team_label)
109+ . prompt ( ) ?;
110+ team = team_label;
111+
101112 url
102113 } else {
103114 Text :: new ( "At what URL can people find the team?" )
@@ -179,6 +190,22 @@ being published - CI checks against the placeholder.
179190 Ok ( ( ) )
180191}
181192
193+ /// Normalizes team name to be human readable, e.g. `leadership-council` => `Leadership Council`.
194+ fn normalize_team_name ( name : String ) -> String {
195+ name. split ( "-" )
196+ . map ( |part| {
197+ // Capitalize the string
198+ part. chars ( )
199+ . next ( )
200+ . into_iter ( )
201+ . flat_map ( |c| c. to_uppercase ( ) )
202+ . chain ( part. chars ( ) . skip ( 1 ) )
203+ . collect :: < String > ( )
204+ } )
205+ . collect :: < Vec < _ > > ( )
206+ . join ( " " )
207+ }
208+
182209fn load_teams ( ) -> Result < Teams , String > {
183210 let url = format ! ( "{}/teams.json" , rust_team_data:: v1:: BASE_URL ) ;
184211 let response = ureq:: get ( url) . call ( ) . map_err ( |e| e. to_string ( ) ) ?;
0 commit comments