@@ -13,6 +13,7 @@ import (
1313 "path/filepath"
1414 "sort"
1515 "strings"
16+ "unicode"
1617
1718 bubspinner "github.com/charmbracelet/bubbles/spinner"
1819 tea "github.com/charmbracelet/bubbletea"
@@ -96,6 +97,7 @@ func main() {
9697 uploadFormat := flag .String ("upload-format" , "docx" , "Upload format when using rclone: docx (Google Doc import) or pdf" )
9798 pdfEngine := flag .String ("pdf-engine" , "" , "Preferred PDF engine for pandoc (e.g., tectonic, xelatex). Leave empty for auto." )
9899 copyTemplates := flag .Bool ("copy-templates" , false , "Copy template docs into the Drive folder after export" )
100+ censorFlag := flag .Bool ("censor" , false , "Censor reviewer names, scores, and quotes in the output" )
99101 templateHubID := flag .String ("template-hub-id" , "1HU2Jm_JLaLOLPR6V6HjPI4VzwzZRw_OCOvsT3rC_8G0" , "Google Doc file ID for the Hub template" )
100102 templateCoverID := flag .String ("template-cover-id" , "1vX9gElaEXkQYReZTEb1151x1JnYDSw64eObiWjS7Sp4" , "Google Doc file ID for the Cover template" )
101103 templateReviewID := flag .String ("template-review-id" , "1OLd7jgwsoKSFiTsiWtOjw9k_c9BfNhx0XRFdMYDaLP0" , "Google Doc file ID for the Review template" )
@@ -219,7 +221,7 @@ func main() {
219221
220222 selectedUserName := reports [selIdx ].Name
221223 mdAny , err := runWithSpinner (ctx , "Generating markdown..." , func (c context.Context ) (any , error ) {
222- return buildMarkdown (c , client , selectedUserName , filtered [idx ].Name , reviews )
224+ return buildMarkdown (c , client , selectedUserName , filtered [idx ].Name , reviews , * censorFlag )
223225 })
224226 if err != nil {
225227 log .Fatalf ("build markdown failed: %v" , err )
@@ -440,7 +442,21 @@ func (m *listModel) View() string {
440442 return b .String ()
441443}
442444
443- func buildMarkdown (ctx context.Context , c * api.Client , userName , cycleName string , reviews []api.Review ) (string , error ) {
445+ func buildMarkdown (ctx context.Context , c * api.Client , userName , cycleName string , reviews []api.Review , censor bool ) (string , error ) {
446+ mask := func (s string ) string {
447+ if ! censor {
448+ return s
449+ }
450+ var b strings.Builder
451+ for _ , r := range s {
452+ if unicode .IsSpace (r ) {
453+ b .WriteRune (r )
454+ } else {
455+ b .WriteRune ('▒' )
456+ }
457+ }
458+ return b .String ()
459+ }
444460 peerByQ := make (map [string ][]api.Review )
445461 selfByQ := make (map [string ][]api.Review )
446462 qOrderPeer , qOrderSelf := make ([]string , 0 ), make ([]string , 0 )
@@ -495,9 +511,9 @@ func buildMarkdown(ctx context.Context, c *api.Client, userName, cycleName strin
495511 score = fmt .Sprintf ("%.2f" , * r .Response .Rating )
496512 }
497513 if score != "" {
498- fmt .Fprintf (& b , "%s (score: %s):\n \n " , name , score )
514+ fmt .Fprintf (& b , "%s (score: %s):\n \n " , mask ( name ), mask ( score ) )
499515 } else {
500- fmt .Fprintf (& b , "%s:\n \n " , name )
516+ fmt .Fprintf (& b , "%s:\n \n " , mask ( name ) )
501517 }
502518 quote := ""
503519 if r .Response .Comment != nil && strings .TrimSpace (* r .Response .Comment ) != "" {
@@ -508,7 +524,7 @@ func buildMarkdown(ctx context.Context, c *api.Client, userName, cycleName strin
508524 if strings .TrimSpace (quote ) == "" {
509525 quote = "(no comment)"
510526 }
511- for _ , line := range strings .Split (quote , "\n " ) {
527+ for _ , line := range strings .Split (mask ( quote ) , "\n " ) {
512528 fmt .Fprintf (& b , "> %s\n " , line )
513529 }
514530 b .WriteString ("\n " )
@@ -534,7 +550,7 @@ func buildMarkdown(ctx context.Context, c *api.Client, userName, cycleName strin
534550 if strings .TrimSpace (quote ) == "" {
535551 quote = "(no comment)"
536552 }
537- for _ , line := range strings .Split (quote , "\n " ) {
553+ for _ , line := range strings .Split (mask ( quote ) , "\n " ) {
538554 fmt .Fprintf (& b , "> %s\n " , line )
539555 }
540556 b .WriteString ("\n " )
0 commit comments