Skip to content

Commit

Permalink
remove unused proc and mention of interactive session (#25099)
Browse files Browse the repository at this point in the history
Fixes #25071

[ contributed by @lucaferranti, merged + reviewed by me ]
  • Loading branch information
bmcdonald3 authored May 23, 2024
2 parents 908becd + dfcc0b6 commit 79f7866
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 118 deletions.
3 changes: 1 addition & 2 deletions doc/rst/tools/mason/guide/basicusage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ To initialize a new mason package, run ``mason new``. The same can also be done
cd newPackage
mason init
This starts an interactive session which walks a user through the process of creating a project using Mason. This is highly recommended for new users.
This sets up a folder to have the structure of a mason package. Particularly, it creates a `Mason.toml` file and the `src` folder with the package main module.

A more advanced user may use the ``mason new [ options ] <project name>`` command, for example::

Expand Down
1 change: 0 additions & 1 deletion tools/mason/MasonHelp.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ proc masonBuildHelp() {
proc masonNewHelp() {
writeln('Usage:');
writeln(' mason new [options] <project name>');
writeln(' mason new Starts an interactive session');
writeln();
writeln('Options:');
writeln(' -h, --help Display this message');
Expand Down
115 changes: 0 additions & 115 deletions tools/mason/MasonNew.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,121 +99,6 @@ proc masonNew(args: [] string) throws {
}
}

/*
Starts an interactive session to create a
new library project.
*/
proc beginInteractiveSession(defaultPackageName: string, defVer: string,
defChplVer: string, license: string) throws {
writeln("""This is an interactive session to walk you through creating a library
project using Mason. The following queries covers the common items required to
create the project. Suggestions for defaults are also provided which will be
considered if no input is given.""");
writeln();
writeln("Press ^C to quit interactive mode.");
var packageName: string;
var defPackageName: string = defaultPackageName;
var version: string;
var defaultVersion = if defVer == '' then "0.1.0" else defVer;
var chapelVersion: string;
var currChapelVersion = if defChplVer == '' then getChapelVersionStr() else defChplVer;
var defaultLicense = if license == '' then "None" else license;
var currLicense: string;
var gotCorrectPackageName = false;
var gotCorrectPackageVersion = false;
var gotCorrectChapelVersion = false;
var gotCorrectLicense = false;
while(1){
try {
if !gotCorrectPackageName {
write("Package name");
if defPackageName != '' then write(" (" + defPackageName + ")");
write(": ");
IO.stdout.flush();
IO.stdin.readLine(packageName);
exitOnEOF(packageName);
packageName = packageName.strip();
if packageName == '' then
packageName = defPackageName;
var isIllegalName: bool = false;
if !isIdentifier(packageName) {
isIllegalName = true;
throw new owned MasonError("Bad package name '"+ packageName + "' - only Chapel" +
" identifiers are legal package names.");
}
if !isIllegalName {
if isDir('./' + packageName) then
throw new owned MasonError("Bad package name. A package with the name '"
+ packageName + "' already exists.");
if validatePackageName(packageName) then
gotCorrectPackageName = true;
}
}
if !gotCorrectPackageVersion {
write("Package version (" + defaultVersion + "): ");
IO.stdout.flush();
IO.stdin.readLine(version);
exitOnEOF(version);
version = version.strip();
if version == "" then version = defaultVersion;
checkVersion(version);
gotCorrectPackageVersion = true;
}
if !gotCorrectChapelVersion {
write("Chapel version (" + currChapelVersion + "): ");
IO.stdout.flush();
IO.stdin.readLine(chapelVersion);
exitOnEOF(chapelVersion);
chapelVersion = chapelVersion.strip();
if chapelVersion == "" then chapelVersion = currChapelVersion;
if chapelVersion == currChapelVersion then gotCorrectChapelVersion = true;
else if validateChplVersion(chapelVersion)
then gotCorrectChapelVersion = true;
}
if !gotCorrectLicense {
write("License (" + defaultLicense + "): ");
IO.stdout.flush();
IO.stdin.readLine(currLicense);
exitOnEOF(currLicense);
currLicense = currLicense.strip();
if currLicense == "" then currLicense = defaultLicense;
gotCorrectLicense = true;
}
if gotCorrectPackageName &&
gotCorrectPackageVersion &&
gotCorrectChapelVersion &&
gotCorrectLicense {
previewMasonFile(packageName, version, chapelVersion, currLicense);
writeln();
write("Is this okay ? (Y/N): ");
IO.stdout.flush();
var option: string;
IO.stdin.readLine(option);
exitOnEOF(option);
option = option.strip();
option = option.toUpper();
if option == "Y" then break;
if option == "N" then {
gotCorrectChapelVersion = false;
gotCorrectPackageName = false;
gotCorrectPackageVersion = false;
gotCorrectLicense = false;
defaultVersion = version;
currChapelVersion = chapelVersion;
defPackageName = packageName;
defaultLicense = currLicense;
continue;
}
}
}
catch e: MasonError {
writeln(e.message());
continue;
}
}
return (packageName, version, chapelVersion, currLicense);
}

/* Exit terminal when CTRL + D is pressed */
proc exitOnEOF(parameter) {
if parameter == '' {
Expand Down

0 comments on commit 79f7866

Please sign in to comment.