-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinit.cpp
More file actions
32 lines (24 loc) · 803 Bytes
/
init.cpp
File metadata and controls
32 lines (24 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <cstdlib>
#include "cppship/cmd/init.h"
#include "cppship/core/manifest.h"
#include "cppship/core/template.h"
#include "cppship/exception.h"
#include "cppship/util/fs.h"
#include "cppship/util/log.h"
using namespace cppship;
int cmd::run_init(const InitOptions& options)
{
if (options.lib && options.bin) {
throw Error { "--bin and --lib cannot co-exist" };
}
const std::string name = options.name.value_or(options.dir.filename().string());
generate_manifest(name, options.std, options.dir);
if (options.lib) {
generate_lib_template(options.dir);
status("created", "library `{}` package", name);
} else {
generate_bin_template(options.dir);
status("created", "binary `{}` package", name);
}
return EXIT_SUCCESS;
}