-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move the logic parts in Main program to Entrypoint
Signed-off-by: Thanabodee Charoenpiriyakij <wingyminus@gmail.com>
- Loading branch information
Showing
7 changed files
with
133 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
namespace Potato; | ||
|
||
[Serializable] | ||
[Mod.Entrypoint] | ||
[Mod.Object] | ||
public partial class Potato | ||
{ | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,9 @@ | ||
// QUESTION: is it possible to get generate by source generator? | ||
|
||
using System.Text.Json; | ||
using Dagger.SDK; | ||
using Dagger.SDK.Mod; | ||
|
||
public class Program | ||
{ | ||
public static async Task Main(string[] args) | ||
{ | ||
var dag = Dagger.SDK.Dagger.Connect(); | ||
await Invoke<Potato.Potato>(dag); | ||
} | ||
|
||
private static async Task Invoke<T>(Query dag) where T : class, IDagSetter, IEntrypoint, new() | ||
{ | ||
T root = new(); | ||
var fnCall = dag.CurrentFunctionCall(); | ||
var parentName = await fnCall.ParentName(); | ||
// TODO: Get module name to check root type name match with it. | ||
|
||
var result = parentName switch | ||
{ | ||
// TODO: Dagger.SDK should automatic serialize into id. | ||
"" => await root.Register(dag).Id(), | ||
_ => throw new Exception($"{parentName} is not supported at the moment.") | ||
}; | ||
|
||
await fnCall.ReturnValue(IntoJson(result)); | ||
} | ||
|
||
private static Json IntoJson(object result) | ||
{ | ||
return new Json { Value = JsonSerializer.Serialize(result) }; | ||
} | ||
namespace Potato; | ||
|
||
public static class Program | ||
{ | ||
public static async Task Main(string[] args) | ||
{ | ||
await Entrypoint.Invoke(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters