Skip to content

Commit

Permalink
Implement Program class and basic architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Mar 5, 2024
1 parent aae0d96 commit f18b040
Show file tree
Hide file tree
Showing 16 changed files with 677 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ indent_size = 2
# C# files
[*.cs]

# CA1056: Uri properties should not be strings
dotnet_diagnostic.CA1056.severity = none

# CA1303: Do not pass literals as localized parameters
dotnet_diagnostic.CA1303.severity = none # Don't need translated exceptions

Expand Down
4 changes: 3 additions & 1 deletion EthernaGatewayCli.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</s:String></wpf:ResourceDictionary>
limitations under the License.</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EFeature_002EServices_002ECodeCleanup_002EFileHeader_002EFileHeaderSettingsMigrate/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=etherna/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@ Etherna Gateway CLI requires at least [.NET 8 Runtime](https://dotnet.microsoft.
### How to use

```
<TO_DO>
Usage: etherna [OPTIONS] COMMAND
Commands:
download Download a resource from Swarm
postage Manage postage batches
resource Manage resources on Gateway
upload Upload a resource to Swarm
General Options:
-k, --api-key Api Key (optional)
-i, --ignore-update Ignore new version of EthernaGatewayCli
Run 'etherna -h' or 'etherna --help' to print help.
Run 'etherna COMMAND -h' or 'etherna COMMAND --help' for more information on a command.
```

# Issue reports
Expand Down
37 changes: 37 additions & 0 deletions src/EthernaGatewayCli/Commands/DownloadCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2024-present Etherna SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;

namespace Etherna.GatewayCli.Commands
{
public class DownloadCommand : ICommand
{
// Properties.
public string Description => "Download a resource from Swarm";
public string Name => "download";

// Methods.
public void PrintHelp()
{
throw new NotImplementedException();
}

public Task RunAsync(string[] args)
{
throw new NotImplementedException();
}
}
}
29 changes: 29 additions & 0 deletions src/EthernaGatewayCli/Commands/ICommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2024-present Etherna SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Threading.Tasks;

namespace Etherna.GatewayCli.Commands
{
public interface ICommand
{
// Properties.
string Description { get; }
string Name { get; }

// Methods.
void PrintHelp();
Task RunAsync(string[] args);
}
}
37 changes: 37 additions & 0 deletions src/EthernaGatewayCli/Commands/PostageCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2024-present Etherna SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;

namespace Etherna.GatewayCli.Commands
{
public class PostageCommand : ICommand
{
// Properties.
public string Description => "Manage postage batches";
public string Name => "postage";

// Methods.
public void PrintHelp()
{
throw new NotImplementedException();
}

public Task RunAsync(string[] args)
{
throw new NotImplementedException();
}
}
}
37 changes: 37 additions & 0 deletions src/EthernaGatewayCli/Commands/ResourceCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2024-present Etherna SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;

namespace Etherna.GatewayCli.Commands
{
public class ResourceCommand : ICommand
{
// Properties.
public string Description => "Manage resources on Gateway";
public string Name => "resource";

// Methods.
public void PrintHelp()
{
throw new NotImplementedException();
}

public Task RunAsync(string[] args)
{
throw new NotImplementedException();
}
}
}
37 changes: 37 additions & 0 deletions src/EthernaGatewayCli/Commands/UploadCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2024-present Etherna SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;
using System.Threading.Tasks;

namespace Etherna.GatewayCli.Commands
{
public class UploadCommand : ICommand
{
// Properties.
public string Description => "Upload a resource to Swarm";
public string Name => "upload";

// Methods.
public void PrintHelp()
{
throw new NotImplementedException();
}

public Task RunAsync(string[] args)
{
throw new NotImplementedException();
}
}
}
26 changes: 26 additions & 0 deletions src/EthernaGatewayCli/CommonConsts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2024-present Etherna SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.BeeNet.Clients.GatewayApi;

namespace Etherna.GatewayCli
{
public static class CommonConsts
{
public const GatewayApiVersion BeeNodeGatewayVersion = GatewayApiVersion.v5_0_0;
public const string EthernaGatewayCliClientId = "689efb99-e2a3-4cb5-ba86-d1e07a71991f";
public const string EthernaGatewayUrl = "https://gateway.etherna.io/";
public const string EthernaSsoUrl = "https://sso.etherna.io/";
}
}
48 changes: 42 additions & 6 deletions src/EthernaGatewayCli/EthernaGatewayCli.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Etherna.GatewayCli</RootNamespace>

<Authors>Etherna SA</Authors>
<Description>A CLI interface to the Etherna Gateway</Description>

<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>

<InvariantGlobalization>true</InvariantGlobalization>

<AssemblyName>etherna</AssemblyName>
<RepositoryUrl>https://github.com/Etherna/etherna-gateway-cli</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Bee.Net" Version="0.2.0-alpha.218" />
<PackageReference Include="EthernaSdk.Users.Native" Version="0.3.3" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
33 changes: 33 additions & 0 deletions src/EthernaGatewayCli/Models/GitHubDto/GitReleaseVersionDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2024-present Etherna SA
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using System;

namespace Etherna.GatewayCli.Models.GitHubDto
{
public class GitReleaseVersionDto
{
// Properties.
public string Assets_url { get; set; } = default!;
public DateTime Created_at { get; set; }
public bool Draft { get; set; }
public string Html_url { get; set; } = default!;
public int Id { get; set; } = default!;
public string Name { get; set; } = default!;
public bool Prerelease { get; set; }
public DateTime Published_at { get; set; }
public string Tag_name { get; set; } = default!;
public string Url { get; set; } = default!;
}
}
Loading

0 comments on commit f18b040

Please sign in to comment.