Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(src/cli/cli.cc): add --name option to ssc init #613

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/cli/cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,10 @@ optionsAndEnv parseCommandLineOptions (
}

int main (const int argc, const char* argv[]) {
defaultTemplateAttrs = {{ "ssc_version", SSC::VERSION_FULL_STRING }};
defaultTemplateAttrs = {
{ "ssc_version", SSC::VERSION_FULL_STRING },
{ "project_name", "beepboop" }
};
if (argc < 2) {
printHelp("ssc");
exit(0);
Expand Down Expand Up @@ -2139,14 +2142,20 @@ int main (const int argc, const char* argv[]) {
// first flag indicating whether option is optional
// second flag indicating whether option should be followed by a value
Options initOptions = {
{ { "--config" }, true, false }
{ { "--config" }, true, false },
{ { "--name" }, true, true }
};
createSubcommand("init", initOptions, false, [&](Map optionsWithValue, std::unordered_set<String> optionsWithoutValue) -> void {
auto isCurrentPathEmpty = fs::is_empty(fs::current_path());
auto configOnly = optionsWithoutValue.find("--config") != optionsWithoutValue.end();
auto projectName = optionsWithValue["--name"];

if (fs::exists(targetPath / "socket.ini")) {
log("socket.ini already exists in " + targetPath.string());
} else {
if (projectName.size() > 0) {
defaultTemplateAttrs["project_name"] = projectName;
}
SSC::writeFile(targetPath / "socket.ini", tmpl(gDefaultConfig, defaultTemplateAttrs));
log("socket.ini created in " + targetPath.string());
}
Expand Down
21 changes: 11 additions & 10 deletions src/cli/templates.hh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ usage:

options:
--config only create the config file
--name project name
)TEXT";

constexpr auto gHelpTextInstallApp = R"TEXT(
Expand Down Expand Up @@ -1406,7 +1407,7 @@ flags = -O3
headless = false

; The name of the program and executable to be output. Can't contain spaces or special characters. Required field.
name = "beepboop"
name = "{{project_name}}"

; The binary output path. It's recommended to add this path to .gitignore.
; default value: "build"
Expand Down Expand Up @@ -1440,13 +1441,13 @@ flags = "-g"
; A unique ID that identifies the bundle (used by all app stores).
; It's required when `[meta] type` is not `"extension"`.
; It should be in a reverse DNS notation https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundleidentifier#discussion
bundle_identifier = "com.beepboop"
bundle_identifier = "com.{{project_name}}"

; A string that gets used in the about dialog and package meta info.
copyright = "(c) Beep Boop Corp. 1985"
; copyright = "(c) Beep Boop Corp. 1985"

; A short description of the app.
description = "A UI for the beep boop network"
; description = "A UI for the beep boop network"

; Set the limit of files that can be opened by your process.
file_limit = 1024
Expand All @@ -1455,10 +1456,10 @@ file_limit = 1024
lang = "en-us"

; A String used in the about dialog and meta info.
maintainer = "Beep Boop Corp."
; maintainer = "Beep Boop Corp."

; The title of the app used in metadata files. This is NOT a window title. Can contain spaces and special characters. Defaults to name in a [build] section.
title = "Beep Boop"
title = "{{project_name}}"

; Builds an extension when set to "extension".
; default value: ""
Expand Down Expand Up @@ -1512,7 +1513,7 @@ simulator_device = "iPhone 14"
categories = "Developer Tools"

; The command to execute to spawn the "back-end" process.
cmd = "beepboop"
; cmd = "node backend/index.js"

; The icon to use for identifying your app in Linux desktop environments.
icon = "src/icon.png"
Expand All @@ -1527,7 +1528,7 @@ appstore_icon = "src/icons/icon.png"
category = ""

; The command to execute to spawn the "back-end" process.
cmd = ""
; cmd = "node backend/index.js"

; The icon to use for identifying your app on MacOS.
icon = ""
Expand All @@ -1552,7 +1553,7 @@ headers = native-module1.hh
[win]

; The command to execute to spawn the “back-end” process.
cmd = "beepboop.exe"
; cmd = "node backend/index.js"

; The icon to use for identifying your app on Windows.
icon = ""
Expand All @@ -1564,7 +1565,7 @@ logo = "src/icons/icon.png"
pfx = "certs/cert.pfx"

; The signing information needed by the appx api.
publisher = "CN=Beep Boop Corp., O=Beep Boop Corp., L=San Francisco, S=California, C=US"
; publisher = "CN=Beep Boop Corp., O=Beep Boop Corp., L=San Francisco, S=California, C=US"


[window]
Expand Down
Loading