Jelajahi Sumber

References #64. Added optional afterclean. Updates man page. Adds entries to --help

Jguer 7 tahun lalu
induk
melakukan
4c7f341dd2
4 mengubah file dengan 136 tambahan dan 83 penghapusan
  1. 16 4
      cmd.go
  2. 3 1
      config.go
  3. 4 0
      install.go
  4. 113 78
      yay.8

+ 16 - 4
cmd.go

@@ -31,12 +31,20 @@ func usage() {
 	yay -G [package(s)]  get pkgbuild from ABS or AUR
 	yay --gendb          generates development package DB used for updating.
 
-	New options:
+	Permanent configuration options:
 	--topdown            shows repository's packages first and then aur's
 	--bottomup           shows aur's packages first and then repository's
-	--noconfirm          skip user input on package install
 	--devel              Check -git/-svn/-hg development version
-	--nodevel            Disable development version checking`)
+	--nodevel            Disable development version checking
+	--afterclean         Clean package sources after successful build
+	--noafterclean       Disable package sources cleaning after successful build
+	--timeupdate         Check package's modification date and version
+	--notimeupdate       Check only package version change
+
+	New options:
+	--noconfirm          skip user input on package install
+	--printconfig        Prints current yay configuration
+	`)
 }
 
 func init() {
@@ -155,8 +163,12 @@ func parser() (op string, options []string, packages []string, changedConfig boo
 		if strings.HasPrefix(arg, "--") {
 			changedConfig = true
 			switch arg {
+			case "--afterclean":
+				config.CleanAfter = true
+			case "--noafterclean":
+				config.CleanAfter = false
 			case "--printconfig":
-				fmt.Printf("%+v", config)
+				fmt.Printf("%#v", config)
 				os.Exit(0)
 			case "--gendb":
 				err = createDevelDB()

+ 3 - 1
config.go

@@ -27,6 +27,7 @@ const (
 // Configuration stores yay's config.
 type Configuration struct {
 	BuildDir      string `json:"buildDir"`
+	CleanAfter    bool   `json:"cleanAfter"`
 	Editor        string `json:"editor"`
 	MakepkgBin    string `json:"makepkgbin"`
 	Shell         string `json:"-"`
@@ -41,7 +42,7 @@ type Configuration struct {
 	Devel         bool   `json:"devel"`
 }
 
-const version = "2.201"
+const version = "2.217"
 
 // baseURL givers the AUR default address.
 const baseURL string = "https://aur.archlinux.org"
@@ -106,6 +107,7 @@ func defaultSettings(config *Configuration) {
 		panic(err)
 	}
 	config.BuildDir = fmt.Sprintf("/tmp/yaytmp-%s/", u.Uid)
+	config.CleanAfter = false
 	config.Editor = ""
 	config.Devel = false
 	config.MakepkgBin = "/usr/bin/makepkg"

+ 4 - 0
install.go

@@ -164,6 +164,10 @@ func PkgInstall(a *rpc.Pkg, flags []string) (finalmdeps []string, err error) {
 	err = makepkgcmd.Run()
 	if err == nil {
 		_ = saveVCSInfo()
+		if config.CleanAfter {
+			fmt.Println("\x1b[1;32m==> CleanAfter enabled. Deleting source folder.\x1b[0m")
+			os.RemoveAll(dir)
+		}
 	}
 	return
 }

+ 113 - 78
yay.8

@@ -66,108 +66,143 @@ Display repository packages first and then AUR packages\&.
 Show AUR packages first and then repository packages\&.
 .RE
 .PP
-\fB\-\-noconfirm\fR
+\fB\-\-devel\fR
 .RS 4
-No user intervention needed unless a package conflict happens. This option will be passed to pacman and makepkg\&.
+Check -git/-svn/-hg development version\&.
 .RE
 .PP
-All other options will be passed to pacman\&.
+\fB\-\-nodevel\fR
+.RS 4
+Disable development version checking\&.
+.RE
 .PP
-.SH "EXAMPLES"
-.sp
+\fB\-\-afterclean\fR
 .RS 4
-.ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Sync and update packages from repository and AUR:
-yay \-Syu
+Clean package sources after successful build\&.
 .RE
-.sp
+.PP
+\fB\-\-noafterclean\fR
 .RS 4
-.ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Check installed packages health:
-yay \-Qstats
+Disable package sources cleaning after successful build\&.
 .RE
 .PP
-.sp
-For a package called \fIname\fR:
-.sp
+\fB\-\-timeupdate\fR
 .RS 4
-.ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Search:
-yay \-Ss \fIname\fR
+Check package's modification date and version\&.
 .RE
-.sp
+.PP
+\fB\-\-notimeupdate\fR
 .RS 4
-.ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Install:
-yay \-S \fIname\fR
+Check only package version change\&.
 .RE
+.PP
+\fB\-\-printconfig\fR
+.RS 4
+Prints current yay configuration\&.
+.RE
+.PP
+\fB\-\-noconfirm\fR
+.RS 4
+No user intervention needed unless a package conflict happens. This option will be passed to pacman and makepkg\&.
+.RE
+.PP
+All other options will be passed to pacman\&.
+.PP
+.SH "EXAMPLES"
 .sp
 .RS 4
 .ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Install without confirmations:
-yay \-S \-\-noconfirm \fIname\fR
+        \h'-04'\(bu\h'+03'\c
+        .\}
+        .el \{\
+            .sp -1
+            .IP \(bu 2.3
+            .\}
+            Sync and update packages from repository and AUR:
+            yay \-Syu
+            .RE
+            .sp
+            .RS 4
+            .ie n \{\
+                \h'-04'\(bu\h'+03'\c
+                .\}
+                .el \{\
+                    .sp -1
+                    .IP \(bu 2.3
+                    .\}
+                    Check installed packages health:
+                    yay \-Qstats
+                    .RE
+                    .PP
+                    .sp
+                    For a package called \fIname\fR:
+                    .sp
+                    .RS 4
+                    .ie n \{\
+                        \h'-04'\(bu\h'+03'\c
+                        .\}
+                        .el \{\
+                            .sp -1
+                            .IP \(bu 2.3
+                            .\}
+Search:
+yay \-Ss \fIname\fR
 .RE
 .sp
 .RS 4
 .ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Get information about a package:
-yay \-Si \fIname\fR
+        \h'-04'\(bu\h'+03'\c
+        .\}
+        .el \{\
+            .sp -1
+            .IP \(bu 2.3
+            .\}
+Install:
+yay \-S \fIname\fR
 .RE
 .sp
 .RS 4
 .ie n \{\
-\h'-04'\(bu\h'+03'\c
-.\}
-.el \{\
-.sp -1
-.IP \(bu 2.3
-.\}
-Search and install using yogurt mode:
-yay \fIname\fR
-.RE
-.SH "SEE ALSO"
-.sp
+        \h'-04'\(bu\h'+03'\c
+        .\}
+        .el \{\
+            .sp -1
+            .IP \(bu 2.3
+            .\}
+            Install without confirmations:
+            yay \-S \-\-noconfirm \fIname\fR
+            .RE
+            .sp
+            .RS 4
+            .ie n \{\
+                \h'-04'\(bu\h'+03'\c
+                .\}
+                .el \{\
+                    .sp -1
+                    .IP \(bu 2.3
+                    .\}
+                    Get information about a package:
+                    yay \-Si \fIname\fR
+                    .RE
+                    .sp
+                    .RS 4
+                    .ie n \{\
+                        \h'-04'\(bu\h'+03'\c
+                        .\}
+                        .el \{\
+                            .sp -1
+                            .IP \(bu 2.3
+                            .\}
+                            Search and install using yogurt mode:
+                            yay \fIname\fR
+                            .RE
+                            .SH "SEE ALSO"
+    .sp
 \fBmakepkg\fR(8)
-.sp
+    .sp
 \fBpacman\fR(8)
-.sp
+    .sp
 \fBpacman.conf\fR(5)
-.SH "AUTHORS"
-.sp
-Jguer <joaogg3@gmail\&.com>
+    .SH "AUTHORS"
+    .sp
+    Jguer <joaogg3@gmail\&.com>