private static int Main(string[] args) { PrintTitle(); if (Init()) { return(CommandLineApplication.Execute <Program>(args)); } else { ConsoleHelper.PrintError("您还未设置配置,将引导你设置!"); var setConfig = new CommandSetConfig(); setConfig.Execute(CommandContextStore.Get()); return(0); } }
/// <summary> /// 初始化,加载配置 /// </summary> /// <returns></returns> static bool Init() { var context = new CommandContext(); var docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); context.AppConfigFilePath = Path.Combine(docPath, "dotnet-cnblog", CfgFileName); if (!File.Exists(context.AppConfigFilePath)) { CommandContextStore.Set(context); return(false); } var config = JsonConvert.DeserializeObject <BlogConnectionInfo>(File.ReadAllText(context.AppConfigFilePath)); config.Password = Encoding.UTF8.GetString(TeaHelper.Decrypt(Convert.FromBase64String(config.Password), context.EncryptKey)); context.ConnectionInfo = config; ImageUploadHelper.Init(config); CommandContextStore.Set(context); return(true); }