Vix.cpp v2.6.0 is here Read the blog
Skip to content

vix make

vix make generates C++ files quickly from the folder you are working in.

Use it when you want to create common C++ scaffolding such as classes, structs, enums, functions, concepts, exceptions, tests, lambdas, or JSON runtime config files.

vix make is a file generator. It does not create a full project layout.

Use vix new when you want to create a new project.

Use vix modules when you want structured module scaffolding.

Usage

bash
vix make <kind> <name> [options]
vix make:<kind> [name] [options]
1
2

What it does

vix make generates files in the current directory by default.

If --in is provided, generated files are written inside that folder.

If --dir is provided, it becomes the project root, and --in is resolved from that root.

bash
vix make class User
vix make class User --in src/domain
vix make class User --dir ./apps/api --in src/domain
1
2
3

With the last command, files are generated inside:

txt
./apps/api/src/domain
1

Basic usage

bash
vix make class User
vix make struct Claims
vix make enum Status
vix make function parse_token
vix make lambda visit_all
vix make concept EqualityComparable
vix make exception InvalidToken
vix make test AuthService
vix make config app
1
2
3
4
5
6
7
8
9

Interactive generator form

You can also use the vix make:<kind> form:

bash
vix make:class
vix make:class User
vix make:config
vix make:config app
1
2
3
4

If the name is missing, Vix starts an interactive prompt.

Current interactive support:

KindInteractive support
classYes
configYes
structNot yet
enumNot yet
functionNot yet
lambdaNot yet
conceptNot yet
exceptionNot yet
testNot yet
moduleRedirected to vix modules

Supported kinds

KindWhat it generates
classA C++ class. Generates .hpp and .cpp by default.
structA plain data struct. Header-only by design.
enumAn enum class with helpers. Header-only by design.
functionA free function. Generates .hpp and .cpp by default.
lambdaA modern generic lambda. Header-only by design.
conceptA C++20 concept. Header-only by design.
exceptionA std::exception derived type. Generates .hpp and .cpp by default.
testA GoogleTest skeleton.
moduleRedirects to the modules workflow.
configA JSON runtime configuration file.

Output behavior

By default, vix make behaves like a direct file generator.

It does not force generated files into include/, src/, or tests/.

bash
mkdir src/domain
cd src/domain
vix make class User
1
2
3

This generates:

txt
User.hpp
User.cpp
1
2

Using --in:

bash
vix make class User --in src/domain
1

This generates:

txt
src/domain/User.hpp
src/domain/User.cpp
1
2

Using --dir and --in:

bash
vix make class User --dir ./apps/api --in src/domain
1

This generates:

txt
apps/api/src/domain/User.hpp
apps/api/src/domain/User.cpp
1
2

Project root and default namespace

--dir sets the project root.

If a CMakeLists.txt exists, Vix tries to detect the project name from the CMake project(...) declaration.

That project name is used to guess a default namespace.

Example:

cmake
project(MyApi)
1

Then:

bash
vix make class User --dir .
1

Can use the default namespace:

cpp
namespace myapi
{
}
1
2
3

You can override it:

bash
vix make class User --namespace app::domain
1

Name validation

Names must be valid C++ identifiers.

Valid:

bash
vix make class User
vix make struct AccessToken
vix make enum Status
1
2
3

Invalid:

bash
vix make class 123User
vix make class user-name
vix make class class
1
2
3

C++ reserved keywords are rejected.

Namespace values are also validated:

bash
vix make class User --namespace app::domain
1

Invalid namespace example:

bash
vix make class User --namespace app::class
1

Existing files

Existing files are not overwritten by default.

bash
vix make class User
vix make class User
1
2

The second command fails because the files already exist.

Use --force to overwrite:

bash
vix make class User --force
1

Use --force carefully.

Preview and dry run

Use --dry-run to see what would be generated without writing files:

bash
vix make class User --dry-run
1

Use --print to print the generated preview or snippet:

bash
vix make lambda visit_all --print
vix make class User --print
1
2

Difference:

OptionBehavior
--dry-runPrints the kind, name, and target file paths. Does not write files.
--printPrints the generated preview or code snippet. Does not write files.

Generate a class

bash
vix make class User
1

By default, class generation creates:

txt
User.hpp
User.cpp
1
2

Default class generation includes:

txt
default constructor
value constructor
virtual destructor
copy/move operations
getters and setters
one default field: std::string id
1
2
3
4
5
6

Example:

bash
vix make class User --namespace app::domain
1

Generate in a specific folder:

bash
vix make class User --in src/domain
1

Generate header-only:

bash
vix make class User --header-only
1

Preview:

bash
vix make class User --dry-run
vix make class User --print
1
2

Overwrite existing files:

bash
vix make class User --force
1

Interactive class generation

bash
vix make:class
1

The interactive class generator asks for:

txt
class name
namespace
number of fields
field names and types
default constructor
value constructor
getters/setters
copy/move operations
virtual destructor
header-only mode
target folder
1
2
3
4
5
6
7
8
9
10
11

Example field input:

txt
id:string
email:std::string
age:int
1
2
3

string is normalized to:

cpp
std::string
1

Generate a struct

bash
vix make struct Claims
1

Struct generation is header-only by design.

It creates:

txt
Claims.hpp
1

The generated struct includes a simple data payload skeleton:

txt
id
label
valid
version
tags
1
2
3
4
5

Examples:

bash
vix make struct Claims --namespace auth
vix make struct Claims --in src/auth
1
2

Generate an enum

bash
vix make enum Status
1

Enum generation is header-only by design.

It creates:

txt
Status.hpp
1

The generated enum includes:

txt
enum class Status
to_string(Status)
is_known(Status)
1
2
3

Default enum values:

txt
Unknown
Active
Disabled
1
2
3

Examples:

bash
vix make enum Status --in src/domain
vix make enum Status --namespace app::domain
1
2

Generate a free function

bash
vix make function parse_token
1

By default, function generation creates:

txt
parse_token.hpp
parse_token.cpp
1
2

The generated function uses std::string_view for lightweight input.

Example:

bash
vix make function parse_token --in src/auth
1

Header-only:

bash
vix make function parse_token --header-only
1

Generate a lambda

bash
vix make lambda visit_all
1

Lambda generation is header-only by design.

It creates:

txt
visit_all.hpp
1

The generated lambda is a modern generic lambda:

cpp
inline constexpr auto visit_all = []<typename T>(const T &value)
{
  return value;
};
1
2
3
4

For snippet usage:

bash
vix make lambda visit_all --print
1

Generate a concept

bash
vix make concept EqualityComparable
1

Concept generation is header-only by design.

It creates:

txt
EqualityComparable.hpp
1

The generated concept uses:

txt
requires-expressions
std::convertible_to
std::is_reference_v
1
2
3

It is useful for generic C++20 constraints.

Example:

bash
vix make concept EqualityComparable --namespace app
1

Generate an exception

bash
vix make exception InvalidToken
1

By default, exception generation creates:

txt
InvalidToken.hpp
InvalidToken.cpp
1
2

The generated exception:

txt
derives from std::exception
stores the message in std::string
overrides what() const noexcept
1
2
3

Examples:

bash
vix make exception InvalidToken --in src/auth
vix make exception InvalidToken --namespace auth
vix make exception InvalidToken --header-only
1
2
3

Generate a test

bash
vix make test AuthService
1

Test generation creates a GoogleTest skeleton.

It creates a file like:

txt
test_auth_service.cpp
1

The generated test contains:

cpp
#include <gtest/gtest.h>

TEST(AuthService, DefaultCase)
{
  EXPECT_TRUE(true);
}
1
2
3
4
5
6

Replace EXPECT_TRUE(true) with real assertions.

Example:

bash
vix make test AuthService --in tests
1

Generate a config file

bash
vix make config app
1

Config generation creates a JSON runtime configuration file.

For app, it creates:

txt
app.json
1

By default, config generation includes:

txt
server
logging
waf
1
2
3

By default, it does not include:

txt
websocket
database
1
2

Examples:

bash
vix make config app
vix make config app --websocket --database
vix make config app --server --logging --waf
vix make config app --no-websocket
1
2
3
4

Config sections

OptionMeaning
--serverEnable server section.
--no-serverDisable server section.
--loggingEnable logging section.
--no-loggingDisable logging section.
--wafEnable WAF section.
--no-wafDisable WAF section.
--websocketEnable WebSocket section.
--no-websocketDisable WebSocket section.
--databaseEnable database section.
--no-databaseDisable database section.

At least one config section must be enabled.

This is invalid:

bash
vix make config app \
  --no-server \
  --no-logging \
  --no-waf \
  --no-websocket \
  --no-database
1
2
3
4
5
6

Default config content

Default command:

bash
vix make config app
1

Generates a JSON config with sections like:

json
{
  "server": {
    "port": 8080,
    "request_timeout": 2000,
    "io_threads": 0,
    "session_timeout_sec": 300,
    "bench_mode": true
  },
  "logging": {
    "async": true,
    "queue_max": 20000,
    "drop_on_overflow": true
  },
  "waf": {
    "mode": "off",
    "max_target_len": 4096,
    "max_body_bytes": 1048576
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

With WebSocket:

bash
vix make config app --websocket
1

Adds:

json
"websocket": {
  "port": 9090,
  "max_message_size": 65536,
  "idle_timeout": 60,
  "ping_interval": 30,
  "enable_deflate": true,
  "auto_ping_pong": true
}
1
2
3
4
5
6
7
8

With database:

bash
vix make config app --database
1

Adds:

json
"database": {
  "default": {
    "host": "localhost",
    "port": 3306,
    "name": "mydb",
    "user": "myuser",
    "password": ""
  }
}
1
2
3
4
5
6
7
8
9

Generate a module

bash
vix make module auth
1

Module generation does not belong to vix make.

Vix returns an error and points you to the modules workflow.

Use:

bash
vix modules add auth
1

vix make is for direct file generation.

vix modules is for structured module scaffolding.

Options

OptionDescription
-d, --dir <path>Project root. Default is the current directory.
--in <path>Folder where files should be generated.
--namespace <ns>Override namespace.
--header-onlyGenerate only header files when supported.
--printPrint preview or snippet without writing files.
--dry-runShow what would be generated without writing files.
--forceOverwrite existing files.
--serverEnable server section for config generation.
--no-serverDisable server section for config generation.
--loggingEnable logging section for config generation.
--no-loggingDisable logging section for config generation.
--wafEnable WAF section for config generation.
--no-wafDisable WAF section for config generation.
--websocketEnable WebSocket section for config generation.
--no-websocketDisable WebSocket section for config generation.
--databaseEnable database section for config generation.
--no-databaseDisable database section for config generation.
-h, --helpShow command help.

Common workflows

Generate a domain class

bash
vix make class User --in src/domain --namespace app::domain
1

Generate a header-only class

bash
vix make class User --in include/domain --namespace app::domain --header-only
1

Generate an auth struct

bash
vix make struct Claims --in src/auth --namespace auth
1

Generate an enum for status values

bash
vix make enum Status --in src/domain
1

Generate a parser function

bash
vix make function parse_token --in src/auth
1

Generate a reusable lambda snippet

bash
vix make lambda visit_all --print
1

Generate a C++20 concept

bash
vix make concept EqualityComparable --in src/core
1

Generate a custom exception

bash
vix make exception InvalidToken --in src/auth
1

Generate a test skeleton

bash
vix make test AuthService --in tests
1

Generate app configuration

bash
vix make config app --websocket --database
1

Preview before writing

bash
vix make class User --in src/domain --dry-run
1
bash
vix make lambda visit_all --print
1
bash
# 1. Generate the file
vix make class User --in src/domain --namespace app::domain

# 2. Format generated files
vix fmt

# 3. Build
vix build

# 4. Run tests
vix tests
1
2
3
4
5
6
7
8
9
10
11

For tests:

bash
vix make test AuthService --in tests
vix fmt
vix tests
1
2
3

For config:

bash
vix make config app --websocket --database
vix run
1
2

Common mistakes

Using vix make instead of vix new

vix make generates files.

It does not create a full project layout.

Wrong:

bash
vix make class api
1

Correct for a new project:

bash
vix new api
1

Then generate files inside the project:

bash
cd api
vix make class User --in src/domain
1
2

Using vix make module instead of vix modules

vix make module redirects to the modules workflow.

Use:

bash
vix modules add auth
1

Confusing --dir and --in

--dir is the project root.

--in is the output folder.

bash
vix make class User --dir ./apps/api --in src/domain
1

This means:

txt
project root: ./apps/api
output folder: ./apps/api/src/domain
1
2

Expecting files to be generated in include/ and src/

vix make does not force include/ or src/.

It writes into the current folder by default.

bash
cd src/domain
vix make class User
1
2

Generates:

txt
User.hpp
User.cpp
1
2

To write into a specific folder, use:

bash
vix make class User --in src/domain
1

Missing a name

This starts interactive mode when supported:

bash
vix make class
vix make:class
1
2

Direct generation:

bash
vix make class User
1

Interactive mode is currently implemented for:

txt
class
config
1
2

For other kinds, provide the name directly:

bash
vix make struct Claims
vix make enum Status
vix make function parse_token
1
2
3

Using an invalid C++ name

Wrong:

bash
vix make class 123User
vix make class user-name
vix make class class
1
2
3

Correct:

bash
vix make class User
vix make class UserProfile
vix make function parse_token
1
2
3

Overwriting files accidentally

Vix does not overwrite existing files unless --force is provided.

bash
vix make class User --force
1

Use --dry-run first when unsure:

bash
vix make class User --dry-run
1

Disabling every config section

Wrong:

bash
vix make config app \
  --no-server \
  --no-logging \
  --no-waf \
  --no-websocket \
  --no-database
1
2
3
4
5
6

At least one section must remain enabled.

When to use vix make

Use vix make when:

txt
your project already exists
you want to generate one or more C++ files quickly
you want a class, struct, enum, function, concept, exception, lambda, or test skeleton
you want to generate a runtime JSON config file
you want to preview generated code before writing files
1
2
3
4
5

Use vix new when:

txt
you need a new project
you need a full project layout
you need templates such as app, backend, web, vue, game, or library
1
2
3

Use vix modules when:

txt
you need structured module scaffolding
you want module-level folders and integration
you are adding a module to an existing Vix project
1
2
3
CommandPurpose
vix newCreate a new project.
vix modulesManage structured modules.
vix fmtFormat generated files.
vix buildBuild the project.
vix devRun the project in development mode.
vix runBuild and run.
vix checkValidate the project.
vix testsRun tests.

Next step

Continue with formatting.

Open the vix fmt guide

Released under the MIT License.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.