Skip to content

Commit

Permalink
Merge pull request #1329 from onflow/chasefleming/cadence-1.0-message
Browse files Browse the repository at this point in the history
Add Cadence 1.0 messaging
  • Loading branch information
chasefleming authored Jan 6, 2024
2 parents 63643d1 + c16f4cb commit e2e116f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions cmd/flow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
package main

import (
"fmt"
"os"
"strings"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -52,6 +54,34 @@ func main() {
var cmd = &cobra.Command{
Use: "flow",
TraverseChildren: true,
// Messaging for Cadence 1.0 upgrade
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" {

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("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))

}
},
}

// quick commands
Expand Down

0 comments on commit e2e116f

Please sign in to comment.