static void Main(string[] args) { TpConfigReaderWriter tpConfigReader = new TpConfigReaderWriter(); TpConfig tpConfig = tpConfigReader.TpConfig; if (String.IsNullOrEmpty(tpConfig.Origin)) { Console.WriteLine("Please use 'tp connect' to connect to an origin."); return; } if (args.Length == 0) { Console.WriteLine("Please provide a command"); return; } Cli cli = new Cli(tpConfig); cli.ParseAndRun(args).Wait(); }
public TpConfigReaderWriter() { string userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); string tpPath = Path.Combine(userProfilePath, ".tp"); _tpConfigPath = Path.Combine(tpPath, ".tpconfig"); if (Directory.Exists(tpPath) == false) { Directory.CreateDirectory(tpPath); } if (File.Exists(_tpConfigPath)) { TpConfig config = JsonConvert.DeserializeObject <TpConfig>(File.ReadAllText(_tpConfigPath)); this.TpConfig = config; } else { this.TpConfig = new TpConfig(); string json = JsonConvert.SerializeObject(this.TpConfig); File.WriteAllText(_tpConfigPath, json); } }
public Cli(TpConfig tpConfig) { _tpConfig = tpConfig; _client = new HttpClient(); _client.DefaultRequestHeaders.Add("Authorization", new string[] { "Bearer " + _tpConfig.Bearer }); }