Esempio n. 1
0
        public override async Task Run()
        {
            VaultPaths paths;

            if (VaultPath == null)
            {
                paths = new VaultPaths(Environment.CurrentDirectory);
            }
            else
            {
                paths = new VaultPaths(VaultPath);
            }

            var key = PasswordPrompt.PromptPasswordAsHash();

            using var vault = Vault.Open(paths, key);

            if (File.Exists(ToAddPath))
            {
                await vault.AddFileAsync(ToAddPath);

                Notifier.Success(string.Format(Strings.AddCommandAsync_Run_Added_file__0__to_vault, ToAddPath));
            }
            else if (Directory.Exists(ToAddPath))
            {
                var progress = new Progress <ProgressReport>();
                progress.ProgressChanged += ProgressBar.PrintProgressBar;

                await AddDirectory(vault, progress);
            }
        }
        public static Vault Generate(string?vaultPath)
        {
            var key = PasswordPrompt.PromptPasswordAsHash();

            var paths = new VaultPaths(vaultPath);

            return(Vault.Open(paths, key));
        }