File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ usage() {
2828 echo " package create spk"
2929 echo " dev runs '_cp', 'compile' and 'package' commands"
3030 echo " clean|clear remove all *spk files"
31+ echo " lint lint code"
3132 echo " "
3233}
3334
@@ -89,6 +90,7 @@ dependencies() {
8990}
9091
9192compileAll () {
93+ lint
9294 dependencies
9395
9496 # # match arches to go build arches:
@@ -136,7 +138,6 @@ compile() {
136138 _ARCH=" ${1:- " " } "
137139 _GOARM=" ${2:- " " } "
138140 if command -v go > /dev/null; then
139- gofmt -s -w -- package/src/synoedit/* .go
140141 cd package || exit
141142 export GOPATH=$PWD
142143 cd src/synoedit || exit
@@ -211,6 +212,20 @@ package() {
211212 -- *
212213}
213214
215+ lint () {
216+ gofmt -s -w -- package/src/synoedit/* .go
217+ if ! command -v golint > /dev/null || ! command -v revive > /dev/null; then
218+ go get -u golang.org/x/lint/golint
219+ fi
220+
221+ if command -v golint > /dev/null; then
222+ golint package/src/synoedit/* .go
223+ elif command -v revive > /dev/null; then
224+ revive package/src/synoedit/* .go
225+ fi
226+
227+ }
228+
214229CMD=" ${1:- " " } "
215230BUILD_ARCH=" ${2:- " " } "
216231if [ " $CMD " = " compress" ]; then
@@ -234,6 +249,8 @@ elif [ "$CMD" = "dev" ]; then
234249 package
235250elif [ " $CMD " = " clean" ] || [ " $CMD " = " clear" ]; then
236251 clean
252+ elif [ " $CMD " = " lint" ]; then
253+ lint
237254else
238255 usage
239256fi
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ func token() (string, error) {
6060 }
6161 token := r .FindSubmatch (cmdOut )
6262 if len (token ) < 1 {
63- return string (cmdOut ), errors .New ("Sorry , you need to login first! " )
63+ return string (cmdOut ), errors .New ("sorry , you need to login first" )
6464 }
6565 return string (token [1 ]), nil
6666}
Original file line number Diff line number Diff line change @@ -28,10 +28,12 @@ import (
2828 "path/filepath"
2929)
3030
31+ // Config holds the configuration for many Applications specified in the toml database
3132type Config struct {
3233 Applications map [string ]ApplicationConfig `toml:"app"`
3334}
3435
36+ // ApplicationConfig holds the configuration for a single Application
3537type ApplicationConfig struct {
3638 Name string `toml:"name"`
3739 Directory string `toml:"directory"`
@@ -42,6 +44,7 @@ type ApplicationConfig struct {
4244 Action ActionConfig `toml:"action"`
4345}
4446
47+ // ActionConfig holds the configuration for an custom action for an Application
4548type ActionConfig struct {
4649 Label string `toml:"button_label"`
4750 Exec string `toml:"exec"`
@@ -79,6 +82,8 @@ func verifyFile(filePath string, sha256checksum string) bool {
7982}
8083
8184// borrowed from dnscrypt-proxy
85+
86+ // ConfigLoad loads the configuration file
8287func ConfigLoad (configFile * string ) error {
8388 foundConfigFile , err := findConfigFile (configFile )
8489 if err != nil {
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ func okHTML(str ...string) {
9999 * @param strings message The message to send
100100 */
101101func jsonMessage (status int , message ... string ) {
102- okJsonRes := NewHTTPResponse (200 , "OK" )
102+ okJSONRes := NewHTTPResponse (200 , "OK" )
103103 // RSM 1.2 Doesn't allow 'application/json' Content-Type to pass through!
104104 // okJsonRes.ContentType = "application/json;\r\n"
105105 jsonObj := & JSONResponse {
@@ -110,6 +110,6 @@ func jsonMessage(status int, message ...string) {
110110 if err != nil {
111111 panic (err )
112112 }
113- okJsonRes .print (string (jsonBytes ))
113+ okJSONRes .print (string (jsonBytes ))
114114 os .Exit (0 )
115115}
Original file line number Diff line number Diff line change @@ -27,10 +27,13 @@ import (
2727)
2828
2929const (
30+ // AppVersion is the Program Version
3031 AppVersion = "0.0.2"
31- // DefaultConfigFileName = "synoedit.toml"
32- DefaultDatabaseFileName = "database.toml"
32+ // DefaultDatabaseFileName is the main file name for database
33+ DefaultDatabaseFileName = "database.toml"
34+ // DefaultDatabaseSHA256Checksum is used to detect manipulation or corruption
3335 DefaultDatabaseSHA256Checksum = "da745008c71cda6c993f5b448ada798978d28e0ba00e441190a9bcd17a50ad9c"
36+ // DefaultConfigFileName = "synoedit.toml"
3437)
3538
3639// Page contains the data that is passed to the template (layout.html)
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ func GetFilePath(appName string, fileName string) string {
3737 return ""
3838}
3939
40- // Look for command in $PATH or Check that file exits
40+ // CheckCmdExists returns true when the command (cmd)
41+ // is found in the $PATH variable or when the file exits
4142func CheckCmdExists (cmd string ) bool {
4243 _ , err := exec .LookPath (cmd )
4344 if err != nil {
@@ -46,7 +47,7 @@ func CheckCmdExists(cmd string) bool {
4647 return true
4748}
4849
49- // Execute custom action given the application string
50+ // ExecuteAction runs a custom action given the application name
5051func ExecuteAction (appName string ) string {
5152 if app , exists := config .Applications [appName ]; exists {
5253
You can’t perform that action at this time.
0 commit comments