Skip to main content

Add Mode

Sometimes, during development, you may forget about a crucial detail or decide to add something new. For such cases, the Scaffolder provides an "Add Mode", which allows you to insert only new lines without touching the code you've already added.

Simply invoke the CLI in the same directory where your project and configuration are stored, add the "--add true" parameter to enable the Scaffolder to add new lines. Since developer intervention may be required after adding new lines, the program will throw an error if you attempt to call the CLI without this parameter where a project already exists.

Important note: The error will not occur if the contents of an existing file are not different from what should be written.


Let's take an example. Our initial configuration looks like this:

Products:
Models:
Category:
Title: string
Description: string

The resulting file with added lines from the user:

using SharedKernel.Domain;

namespace Domain.Models;

// Custom Code Example Here...
public sealed class Category(Guid id) : Entity(id)
{
// Custom Code Example Here...
public string Title { get; set; }
// Custom Code Example Here...
public string Description { get; set; }
}

Now let's add a couple of new fields:

Products:
Models:
Category:
Title: string
ExpiresAt: DateTime
Description: string
IsPromotional: bool

And yay! We got new lines without touching the old ones:

using SharedKernel.Domain;

namespace Domain.Models;

// Custom Code Example Here...
public sealed class Category(Guid id) : Entity(id)
{
// Custom Code Example Here...
public string Title { get; set; }
public DateTime ExpiresAt { get; set; }
// Custom Code Example Here...
public string Description { get; set; }
public bool IsPromotional { get; set; }
}

That's about it. Remember, you'll probably need to tweak some lines in the project if you've modified it before.