@@ -19,6 +19,7 @@ import (
19
19
"github.com/spf13/cobra"
20
20
"golang.org/x/mod/semver"
21
21
"golang.org/x/term"
22
+ "google.golang.org/protobuf/types/known/emptypb"
22
23
23
24
"github.com/AlecAivazis/survey/v2"
24
25
@@ -605,6 +606,22 @@ var logoutCmd = &cobra.Command{
605
606
},
606
607
}
607
608
609
+ var eulaCmd = & cobra.Command {
610
+ Use : "eula" ,
611
+ Annotations : authNeededAnnotation ,
612
+ Args : cobra .NoArgs ,
613
+ Short : "Read and/or agree the Defang terms of service" ,
614
+ RunE : func (cmd * cobra.Command , args []string ) error {
615
+ agreeToS , _ := cmd .Flags ().GetBool ("agree-tos" )
616
+ cli .Println ("Read our latest terms of service at https://defang.io/terms-conditions.html" )
617
+ if agreeToS {
618
+ _ , err := client .SignEULA (cmd .Context (), & connect.Request [emptypb.Empty ]{})
619
+ return err
620
+ }
621
+ return nil
622
+ },
623
+ }
624
+
608
625
func main () {
609
626
colorMode := ColorAuto
610
627
rootCmd .PersistentFlags ().Var (& colorMode , "color" , `Colorize output; "auto", "always" or "never"` )
@@ -616,6 +633,10 @@ func main() {
616
633
rootCmd .PersistentFlags ().StringP ("cwd" , "C" , "" , "Change directory before running the command" )
617
634
//rootCmd.PersistentFlags().StringVarP(&userLicense, "license", "l", "", "name of license for the project")
618
635
636
+ // Eula command
637
+ eulaCmd .Flags ().Bool ("agree-tos" , false , "Agree to the Defang terms of service" )
638
+ rootCmd .AddCommand (eulaCmd )
639
+
619
640
// Token command
620
641
tokenCmd .Flags ().Duration ("expires" , 24 * time .Hour , "Validity duration of the token" )
621
642
tokenCmd .Flags ().String ("scope" , "" , fmt .Sprintf ("Scope of the token; one of %v (required)" , scope .All ()))
@@ -740,13 +761,16 @@ func main() {
740
761
if code == connect .CodeUnauthenticated {
741
762
printDefangHint ("Please use the following command to log in:" , "login" )
742
763
}
764
+ if code == connect .CodeFailedPrecondition && strings .Contains (err .Error (), "EULA" ) {
765
+ printDefangHint ("Please use the following command to agree to the terms of service:" , "eula --agree-tos" )
766
+ }
743
767
744
768
os .Exit (int (code ))
745
769
}
746
770
747
771
if hasTty && ! pkg .GetenvBool ("DEFANG_HIDE_UPDATE" ) {
748
772
if ver , err := GetLatestVersion (ctx ); err == nil && semver .Compare (GetCurrentVersion (), ver ) < 0 {
749
- cli .Warn ( " ! A newer version of the CLI is available at https://github.com/defang-io/defang/releases/latest" )
773
+ cli .Println ( " A newer version of the CLI is available at https://github.com/defang-io/defang/releases/latest" )
750
774
}
751
775
}
752
776
}
0 commit comments