-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ItalyPaleAle/v0.4-wip
This includes features that will be added to prvt 0.4. - [X] Upload files directly from the UI - [x] Themes and dark mode - [X] Storing file date and type in index - [X] Index file is now encoded with protocol buffers. This requires repos version 3; however, prvt can still read repos v2. - [X] Web UI shows file date and icon - [X] Action item in the file's dropdown menu to force a file to be downloaded - [X] `--store flag` can be passed with the `PRVT_STORE` env var
- Loading branch information
Showing
53 changed files
with
1,791 additions
and
7,861 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
Copyright © 2020 Alessandro Segala (@ItalyPaleAle) | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
|
||
"github.com/ItalyPaleAle/prvt/infofile" | ||
"github.com/ItalyPaleAle/prvt/utils" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Requires a minimum version of the info file to continue | ||
func requireInfoFileVersion(info *infofile.InfoFile, version uint16, connectionString string) bool { | ||
if connectionString == "" { | ||
connectionString = "<string>" | ||
} | ||
|
||
if info.Version < version { | ||
utils.ExitWithError(utils.ErrorUser, "Repository needs to be upgraded", errors.New(`Please run "prvt repo upgrade --store `+connectionString+`" to upgrade this repository to the latest format`)) | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
// Adds the --store flag, with a default value read from the environment | ||
func addStoreFlag(c *cobra.Command, flag *string) { | ||
// Check if we have a value in the PRVT_STORE env var | ||
env := os.Getenv("PRVT_STORE") | ||
c.Flags().StringVarP(flag, "store", "s", env, "connection string for the store") | ||
if env == "" { | ||
c.MarkFlagRequired("store") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.