From 00633b14042a18aed725e9ab40c63f79cc10a738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Sch=C3=A4fer?= Date: Thu, 28 Oct 2021 20:15:53 +0200 Subject: [PATCH] Add a command line argument for the currency symbol in the cocomo project cost estimation. --- main.go | 6 ++++++ processor/formatters.go | 2 +- processor/processor.go | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 261bfba11..35da80e1d 100644 --- a/main.go +++ b/main.go @@ -294,6 +294,12 @@ func main() { "", "inspect every file and remap by checking for a string and remapping the language [e.g. \"-*- C++ -*-\":\"C Header\"]", ) + flags.StringVar( + &processor.CurrencySymbol, + "currency-symbol", + "$", + "set currency symbol", + ) if err := rootCmd.Execute(); err != nil { os.Exit(1) diff --git a/processor/formatters.go b/processor/formatters.go index 88583cabd..c8793834d 100644 --- a/processor/formatters.go +++ b/processor/formatters.go @@ -998,7 +998,7 @@ func calculateCocomo(sumCode int64, str *strings.Builder) { p := gmessage.NewPrinter(glang.English) - str.WriteString(p.Sprintf("Estimated Cost to Develop (%s) $%d\n", CocomoProjectType, int64(estimatedCost))) + str.WriteString(p.Sprintf("Estimated Cost to Develop (%s) %s%d\n", CocomoProjectType, CurrencySymbol, int64(estimatedCost))) str.WriteString(fmt.Sprintf("Estimated Schedule Effort (%s) %f months\n", CocomoProjectType, estimatedScheduleMonths)) if math.IsNaN(estimatedPeopleRequired) { str.WriteString(fmt.Sprintf("Estimated People Required 1 Grandparent\n")) diff --git a/processor/processor.go b/processor/processor.go index 3bb859e73..c89ece2b8 100644 --- a/processor/processor.go +++ b/processor/processor.go @@ -118,6 +118,9 @@ var RemapUnknown = "" // RemapAll allows remapping of all files with a string to search the content for var RemapAll = "" +// CurrencySymbol allows setting the currency symbol for cocomo project cost estimation +var CurrencySymbol = "" + // FileOutput sets the file that output should be written to var FileOutput = ""