Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
Update InstaShitCore, add checking for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
konrad11901 committed Apr 19, 2018
1 parent df35abd commit 75c0185
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
6 changes: 2 additions & 4 deletions InstaShit/InstaShit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<TargetFramework>netcoreapp2.0</TargetFramework>
<Authors>Konrad Krawiec</Authors>
<Company />
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>2.1.1</ReleaseVersion>
<AssemblyVersion>2.2</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -20,7 +18,7 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="InstaShitCore" Version="1.0.6" />
<PackageReference Include="InstaShitCore" Version="1.0.7" />
</ItemGroup>

<ItemGroup>
Expand Down
33 changes: 32 additions & 1 deletion InstaShit/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// Created by Konrad Krawiec
using System;
using System.Net.Http;
using System.Reflection;
using System.Threading.Tasks;
using InstaShitCore;
using static InstaShit.UserInput;

namespace InstaShit
{
Expand Down Expand Up @@ -33,6 +35,34 @@ private static async Task Main(string[] args)
break;
}
}
HttpClient client = new HttpClient
{
BaseAddress = new Uri("https://instashit.pl")
};
try
{
string latestVersionString = await client.GetStringAsync("/cli.version");
Version latestVersion = new Version(latestVersionString);
var localVersion = Assembly.GetEntryAssembly().GetName().Version;
if (latestVersion > localVersion)
{
Console.WriteLine("A new version of InstaShit.CLI is available. It is very important " +
"to keep all InstaShit products updated, since Insta.Ling creators sometimes make " +
"changes that require updating InstaShit.");
Console.WriteLine($"Your current version is {localVersion}, while the newest version is {latestVersion}.");
Console.WriteLine("Visit https://instashit.pl to download newest InstaShit.CLI.");
if (!noUserInteraction)
{
Console.Write("Continue without updating? (y/n) ");
if (!CanContinue())
return;
}
}
}
catch (Exception ex)
{
Console.WriteLine("An error occured while trying to check for updates: " + ex);
}
try
{
var instaShit = new InstaShit(ignoreSettings);
Expand All @@ -52,7 +82,8 @@ private static async Task Main(string[] args)
if (!noUserInteraction)
{
Console.Write("Continue (y/n)? ");
if (!UserInput.CanContinue()) return;
if (!CanContinue())
return;
}
}
while (true)
Expand Down

0 comments on commit 75c0185

Please sign in to comment.