Example #1
0
        bool CheckManualSetup()
        {
            if (!Config.CheckFileExists(SessionState.Path.CurrentLocation.Path))
            {
                WriteWarning($"Cannot initialize workspace without configuration. Run '{CmdLetExtensions.GetCmdletName<ConfigCommand>()}' then run '{CmdLetExtensions.GetCmdletName<InitializeWorkspaceCommand>()}'");
                return(false);
            }

            var config = this.ReadConfig();

            if (config.UseLocalAccounts && (GlobalVariables.AccountKeys?.Length).GetValueOrDefault() == 0)
            {
                var localAcountsFile = LocalAccountsUtil.GetDefaultFilePath(SessionState.Path.CurrentLocation.Path);
                if (!File.Exists(localAcountsFile))
                {
                    WriteWarning($"Accounts must be first created to initialize workspace using local accounts. Run '{CmdLetExtensions.GetCmdletName<NewAccountsCommand>()}' then run '{CmdLetExtensions.GetCmdletName<InitializeWorkspaceCommand>()}'");
                    return(false);
                }

                if (LocalAccountsUtil.IsEncrypted(localAcountsFile))
                {
                    WriteWarning($"Accounts are encrypted and must be loaded with a password before initialize workspace. Run '{CmdLetExtensions.GetCmdletName<LoadAccountsCommand>()}' then run '{CmdLetExtensions.GetCmdletName<InitializeWorkspaceCommand>()}'");
                    return(false);
                }
            }

            return(true);
        }