From 0e248419a0960bd02c55ed1982b20e6b6b4e4357 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:53:17 -0800 Subject: [PATCH 1/4] Add Cadence 1.0 messaging --- cmd/flow/main.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/cmd/flow/main.go b/cmd/flow/main.go index 1b77738b6..c5ccefe89 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -20,7 +20,9 @@ package main import ( + "fmt" "os" + "strings" "github.com/spf13/cobra" @@ -52,6 +54,36 @@ func main() { var cmd = &cobra.Command{ Use: "flow", TraverseChildren: true, + // Messaging for Cadence 1.0 upgrade + PersistentPostRun: func(cmd *cobra.Command, args []string) { + outputFlag, _ := cmd.Flags().GetString("output") + // If output is set to json, do not append any message + if outputFlag != "json" { + + width := 80 + url := "https://developers.flow.com/build/cadence-migration-guide" + + // Function to center text within a given width + centerText := func(text string, width int) string { + space := (width - len(text)) / 2 + if space < 0 { + space = 0 + } + return fmt.Sprintf("%s%s%s", strings.Repeat(" ", space), text, strings.Repeat(" ", space)) + } + + fmt.Println(strings.Repeat("+", width)) + fmt.Println(centerText("⚠ Upgrade to Cadence 1.0", width)) + fmt.Println(centerText("You are currently using a version of this tool that", width)) + fmt.Println(centerText("precedes a network upgrade, which will require support", width)) + fmt.Println(centerText("for version 1.0 of the Cadence smart contract", width)) + fmt.Println(centerText("programming language. To learn how to upgrade,", width)) + fmt.Println(centerText("please visit our migration guide here:", width)) + fmt.Println(centerText(url, width)) + fmt.Println(strings.Repeat("+", width)) + + } + }, } // quick commands From 24ae442eba1a553adab8cb6fa23d2ac4f5ed5369 Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Fri, 5 Jan 2024 14:57:50 -0800 Subject: [PATCH 2/4] Remove unnecessary text --- cmd/flow/main.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/flow/main.go b/cmd/flow/main.go index c5ccefe89..67b81b84f 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -76,8 +76,7 @@ func main() { fmt.Println(centerText("⚠ Upgrade to Cadence 1.0", width)) fmt.Println(centerText("You are currently using a version of this tool that", width)) fmt.Println(centerText("precedes a network upgrade, which will require support", width)) - fmt.Println(centerText("for version 1.0 of the Cadence smart contract", width)) - fmt.Println(centerText("programming language. To learn how to upgrade,", width)) + fmt.Println(centerText("for version 1.0 of Cadence. To learn how to upgrade,", width)) fmt.Println(centerText("please visit our migration guide here:", width)) fmt.Println(centerText(url, width)) fmt.Println(strings.Repeat("+", width)) From 64e343f68302e57d4f4b7eb3308ce733c3d51dba Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:52:58 -0800 Subject: [PATCH 3/4] Switch to pre --- cmd/flow/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/flow/main.go b/cmd/flow/main.go index 67b81b84f..2ff592542 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -55,7 +55,7 @@ func main() { Use: "flow", TraverseChildren: true, // Messaging for Cadence 1.0 upgrade - PersistentPostRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, args []string) { outputFlag, _ := cmd.Flags().GetString("output") // If output is set to json, do not append any message if outputFlag != "json" { From c16f4cb4f12cf7d3fe68bd7aa48aab17fbe3aaea Mon Sep 17 00:00:00 2001 From: Chase Fleming <1666730+chasefleming@users.noreply.github.com> Date: Fri, 5 Jan 2024 16:52:50 -0800 Subject: [PATCH 4/4] Change message --- cmd/flow/main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/flow/main.go b/cmd/flow/main.go index 2ff592542..0564fd142 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -74,10 +74,9 @@ func main() { fmt.Println(strings.Repeat("+", width)) fmt.Println(centerText("⚠ Upgrade to Cadence 1.0", width)) - fmt.Println(centerText("You are currently using a version of this tool that", width)) - fmt.Println(centerText("precedes a network upgrade, which will require support", width)) - fmt.Println(centerText("for version 1.0 of Cadence. To learn how to upgrade,", width)) - fmt.Println(centerText("please visit our migration guide here:", width)) + fmt.Println(centerText("The Crescendo network upgrade, including Cadence 1.0, is coming soon.", width)) + fmt.Println(centerText("You may need to update your existing contracts to support this change.", width)) + fmt.Println(centerText("Please visit our migration guide here:", width)) fmt.Println(centerText(url, width)) fmt.Println(strings.Repeat("+", width))