Skip to content

Commit

Permalink
Adding output directory overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
Gekctek committed Mar 8, 2023
1 parent 086e3c8 commit eff7b74
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,14 @@ Example:

```
namespace = "My.Namespace" # Base namespace used for generated files
output-directory = "./Clients" # Directory to put clients. Each client will get its own sub folder based on its name
output-directory = "./Clients" # Directory to put clients. Each client will get its own sub folder based on its name. If not specified, will use current directory
[[clients]]
name = "Dex" # Used for the name of the folder and client class
type = "file" # Create client based on service definition file
file-path = "./ServiceDefinitionFiles/Dex.did" # Service definition file path
output-directory = "./Clients/D" # Override base output directory, but this specifies the subfolder
# Can specify multiple clients by defining another
[[clients]]
Expand Down
3 changes: 2 additions & 1 deletion samples/Sample.Shared/candid-client.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ canister-id = "rrkah-fqaaa-aaaaa-aaaaq-cai"
[[clients]]
name = "AddressBook"
type = "file"
file-path = "../ServiceDefinitionFiles/AddressBook.did"
file-path = "../ServiceDefinitionFiles/AddressBook.did"
output-directory = "C:/Git/ICP.NET/samples/Sample.Shared/Address" # override
6 changes: 5 additions & 1 deletion src/ClientGenerator/Tool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ namespace = ""My.Namespace""
# Canister to pull definition from
#canister-id = ""rrkah-fqaaa-aaaaa-aaaaq-cai""
# Override base output directory, but this specifies the subfolder
#output-directory = ""./Clients/MyS""
# Can specify multiple clients by creating another [[clients]]
#[[clients]]
Expand Down Expand Up @@ -120,6 +123,7 @@ private async static Task<int> Generate(GenerateOptions options)
string name = GetRequired<string>(client, "name");
string type = GetRequired<string>(client, "type");
string @namespace = baseNamespace + "." + name;
string? clientOutputDirectory = GetOptional<string>(client, "output-directory");
ClientGenerationOptions clientOptions = new(name, @namespace);
ClientSyntax source;
switch (type)
Expand All @@ -142,7 +146,7 @@ private async static Task<int> Generate(GenerateOptions options)
default:
throw new InvalidOperationException($"Invalid client type '{type}'");
}
WriteClient(source, Path.Combine(outputDirectory , name));
WriteClient(source, Path.Combine(clientOutputDirectory ?? outputDirectory, name));
}
return 0;
}
Expand Down

0 comments on commit eff7b74

Please sign in to comment.