Skip to content

Commit

Permalink
[FIXED] stabilization
Browse files Browse the repository at this point in the history
  • Loading branch information
thevpc committed Dec 1, 2024
1 parent 28031b3 commit 72c4b8b
Show file tree
Hide file tree
Showing 450 changed files with 5,452 additions and 6,114 deletions.
24 changes: 10 additions & 14 deletions companions/nsh/src/main/java/net/thevpc/nuts/toolbox/nsh/Nsh.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.cmdline.NCmdLineRunner;
import net.thevpc.nuts.cmdline.NCmdLineContext;
import net.thevpc.nuts.env.NBootManager;
import net.thevpc.nuts.env.NEnvs;
import net.thevpc.nuts.env.NLauncherOptions;

import net.thevpc.nuts.NLauncherOptions;
import net.thevpc.nuts.text.NTextStyle;
import net.thevpc.nuts.text.NTexts;
import net.thevpc.nuts.toolbox.nsh.nshell.NShell;
Expand Down Expand Up @@ -56,7 +55,6 @@ public void run(NCmdLine cmdLine, NCmdLineContext context) {
}
//id will not include version or
String nshIdStr = NApp.of().getId().get().getShortName();
NConfigs cfg = NConfigs.of();
// HashMap<String, String> parameters = new HashMap<>();
// parameters.put("forList", nshIdStr + " --!color -c find-forCommand");
// parameters.put("find", nshIdStr + " --!color -c find-forCommand %n");
Expand All @@ -81,8 +79,7 @@ public void run(NCmdLine cmdLine, NCmdLineContext context) {
if (!CONTEXTUAL_BUILTINS.contains(command.getName())) {
// avoid recursive definition!
// disable trace, summary will be traced later!
if (NCommands.of(
)
if (session.getWorkspace()
.addCommand(new NCommandConfig()
.setFactoryId("nsh")
.setName(command.getName())
Expand Down Expand Up @@ -120,14 +117,14 @@ public void run(NCmdLine cmdLine, NCmdLineContext context) {
));
}
}
cfg.save(false);
if (NBootManager.of().getBootOptions().getInitScripts()
session.getWorkspace().saveConfig(false);
if (NWorkspace.get().getBootOptions().getInitScripts()
.ifEmpty(true)
.orElse(false)) {
boolean initLaunchers = NBootManager.of().getBootOptions().getInitLaunchers()
boolean initLaunchers = NWorkspace.get().getBootOptions().getInitLaunchers()
.ifEmpty(true)
.orElse(false);
NEnvs.of().addLauncher(
NWorkspace.get().addLauncher(
new NLauncherOptions()
.setId(NApp.of().getId().orNull())
.setCreateScript(true)
Expand Down Expand Up @@ -157,15 +154,14 @@ public void onUninstallApplication() {
NSession session = NSession.of().get();
try {
try {
NCommands.of().removeCommandFactory("nsh");
NWorkspace.get().removeCommandFactory("nsh");
} catch (Exception notFound) {
//ignore!
}
Set<String> uninstalled = new TreeSet<>();
for (NCustomCmd command : NCommands.of().findCommandsByOwner(NApp.of().getId().orNull())) {
for (NCustomCmd command : NWorkspace.get().findCommandsByOwner(NApp.of().getId().orNull())) {
try {
NCommands.of(
).removeCommand(command.getName());
NWorkspace.get().removeCommand(command.getName());
uninstalled.add(command.getName());
} catch (Exception ex) {
if (session.isPlainTrace()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.thevpc.nuts.cmdline.NArgCandidate;
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.cmdline.NCmdLineAutoCompleteResolver;
import net.thevpc.nuts.env.NEnvs;

import net.thevpc.nuts.toolbox.nsh.cmds.NShellBuiltin;
import net.thevpc.nuts.toolbox.nsh.eval.NShellContext;
import net.thevpc.nuts.util.NBlankable;
Expand All @@ -25,7 +25,7 @@ public NshAutoCompleter(NWorkspace workspace) {
public List<NArgCandidate> resolveCandidates(NCmdLine cmdLine, int wordIndex) {
List<NArgCandidate> candidates = new ArrayList<>();
NSession session=workspace.currentSession();
NShellContext fileContext = (NShellContext) NEnvs.of().getProperties().get(NShellContext.class.getName());
NShellContext fileContext = (NShellContext) NWorkspace.get().getProperties().get(NShellContext.class.getName());

if (wordIndex == 0) {
for (NShellBuiltin command : fileContext.builtins().getAll()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import net.thevpc.nuts.*;
import net.thevpc.nuts.cmdline.NArg;
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.env.NLocations;

import net.thevpc.nuts.io.NPath;
import net.thevpc.nuts.spi.NComponentScope;
import net.thevpc.nuts.spi.NScopeType;
Expand Down Expand Up @@ -133,7 +133,7 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) {

shistory.save();
} else {
shistory.save(NPath.of(options.sval).toAbsolute(NLocations.of().getWorkspaceLocation()));
shistory.save(NPath.of(options.sval).toAbsolute(NWorkspace.get().getWorkspaceLocation()));
}
} catch (IOException ex) {
throw new NExecutionException(NMsg.ofC("%s", ex), ex, NExecutionException.ERROR_2);
Expand All @@ -146,7 +146,7 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) {
shistory.clear();
shistory.load();
} else {
shistory.load(NPath.of(options.sval).toAbsolute(NLocations.of().getWorkspaceLocation()));
shistory.load(NPath.of(options.sval).toAbsolute(NWorkspace.get().getWorkspaceLocation()));
}
} catch (IOException ex) {
throw new NExecutionException(NMsg.ofC("%s", ex), ex, NExecutionException.ERROR_2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
import net.thevpc.nuts.*;
import net.thevpc.nuts.cmdline.NArg;
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.env.NEnvs;

import net.thevpc.nuts.spi.NComponentScope;
import net.thevpc.nuts.spi.NScopeType;
import net.thevpc.nuts.toolbox.nsh.cmds.NShellBuiltinDefault;
import net.thevpc.nuts.toolbox.nsh.eval.NShellExecutionContext;
import net.thevpc.nuts.env.NArchFamily;
import net.thevpc.nuts.NArchFamily;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -81,9 +81,9 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) {
NSession session = context.getSession();

Result rr = new Result();
rr.osDist = NEnvs.of().getOsDist();
rr.os = NEnvs.of().getOs();
rr.arch = NEnvs.of().getArchFamily();
rr.osDist = NWorkspace.get().getOsDist();
rr.os = NWorkspace.get().getOs();
rr.arch = NWorkspace.get().getArchFamily();
if (!config.farch && !config.fos && !config.fdist) {
config.farch = true;
config.fos = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import net.thevpc.nuts.cmdline.NArg;
import net.thevpc.nuts.cmdline.NArgName;
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.env.NBootManager;

import net.thevpc.nuts.format.NObjectFormat;
import net.thevpc.nuts.io.NPath;
import net.thevpc.nuts.toolbox.nsh.cmds.NShellBuiltinDefault;
Expand Down Expand Up @@ -316,7 +316,7 @@ private void storeProperties(Map<String, String> p, Options o, NShellExecutionCo
switch (format) {
case AUTO: {
NObjectFormat f = NObjectFormat.of().setValue(p);
f.configure(true, NBootManager.of().getBootOptions().getOutputFormatOptions().orElseGet(Collections::emptyList).toArray(new String[0]));
f.configure(true, NWorkspace.get().getBootOptions().getOutputFormatOptions().orElseGet(Collections::emptyList).toArray(new String[0]));
f.configure(true, session.getOutputFormatOptions().toArray(new String[0]));
f.println(session.out());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import net.thevpc.nuts.*;
import net.thevpc.nuts.cmdline.NArg;
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.env.NLocations;


import net.thevpc.nuts.io.NCp;
import net.thevpc.nuts.io.NPath;
import net.thevpc.nuts.spi.NComponentScope;
Expand Down Expand Up @@ -83,7 +84,7 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) {
for (String value : options.files) {
NAssert.requireNonBlank(value, "file path");
options.xfiles.add(NPath.of((value.contains("://") ? value :
NPath.of(value).toAbsolute(NLocations.of().getWorkspaceLocation()).toString()
NPath.of(value).toAbsolute(NWorkspace.get().getWorkspaceLocation()).toString()
)));
}
if (options.xfiles.size() < 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import net.thevpc.nuts.*;
import net.thevpc.nuts.cmdline.NArg;
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.env.NEnvs;

import net.thevpc.nuts.spi.NComponentScope;
import net.thevpc.nuts.spi.NScopeType;
import net.thevpc.nuts.toolbox.nsh.cmds.NShellBuiltinDefault;
import net.thevpc.nuts.toolbox.nsh.eval.NShellExecutionContext;
import net.thevpc.nuts.env.NOsFamily;
import net.thevpc.nuts.NOsFamily;

import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -56,7 +56,7 @@ public static String resolveJpsCommand(NSession session) {
}

public static String resolveJavaToolCommand(NSession session, String javaHome, String javaCommand) {
String exe = NEnvs.of().getOsFamily().equals(NOsFamily.WINDOWS) ? (javaCommand + ".exe") : javaCommand;
String exe = NWorkspace.get().getOsFamily().equals(NOsFamily.WINDOWS) ? (javaCommand + ".exe") : javaCommand;
if (javaHome == null) {
javaHome = System.getProperty("java.home");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import net.thevpc.nuts.*;
import net.thevpc.nuts.cmdline.NArg;
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.env.NUser;
import net.thevpc.nuts.NUser;
import net.thevpc.nuts.io.NPrintStream;
import net.thevpc.nuts.spi.NComponentScope;
import net.thevpc.nuts.spi.NScopeType;
Expand Down Expand Up @@ -114,7 +114,7 @@ protected void main(NCmdLine cmdLine, NShellExecutionContext context) {
result.remoteId = user.getRemoteIdentity();
}
List<RepoResult> rr = new ArrayList<>();
for (NRepository repository : NRepositories.of().getRepositories()) {
for (NRepository repository : NWorkspace.get().getRepositories()) {
NUser ruser = repository.security().getEffectiveUser(login);
if (ruser != null && (ruser.getGroups().size() > 0
|| ruser.getPermissions().size() > 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.thevpc.nuts.*;
import net.thevpc.nuts.cmdline.*;
import net.thevpc.nuts.elem.NEDesc;
import net.thevpc.nuts.env.NShellFamily;
import net.thevpc.nuts.NShellFamily;
import net.thevpc.nuts.io.NPath;
import net.thevpc.nuts.io.NPrintStream;
import net.thevpc.nuts.toolbox.nsh.autocomplete.NShellAutoCompleteCandidate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
import net.thevpc.nuts.*;
import net.thevpc.nuts.cmdline.NCmdLineHistory;
import net.thevpc.nuts.elem.NEDesc;
import net.thevpc.nuts.env.NEnvs;
import net.thevpc.nuts.env.NLocations;
import net.thevpc.nuts.env.NStoreType;

import net.thevpc.nuts.NStoreType;
import net.thevpc.nuts.io.*;
import net.thevpc.nuts.spi.NDefaultSupportLevelContext;
import net.thevpc.nuts.spi.NSupportLevelContext;
Expand Down Expand Up @@ -181,7 +180,7 @@ public NShell(NShellConfiguration configuration) {
if (session != null) {
NShellContext _rootContext = getRootContext();

NEnvs.of().setProperty(NShellContext.class.getName(), _rootContext);
NWorkspace.get().setProperty(NShellContext.class.getName(), _rootContext);
_rootContext.setSession(session);
//add default commands
List<NShellBuiltin> allCommand = new ArrayList<>();
Expand All @@ -205,7 +204,7 @@ public NShell(NShellConfiguration configuration) {
try {
NPath histFile = this.history.getHistoryFile();
if (histFile == null) {
histFile = NLocations.of().getStoreLocation(this.appId, NStoreType.VAR).resolve((serviceName == null ? "" : serviceName) + ".history");
histFile = NWorkspace.get().getStoreLocation(this.appId, NStoreType.VAR).resolve((serviceName == null ? "" : serviceName) + ".history");
this.history.setHistoryFile(histFile);
if (histFile.exists()) {
this.history.load(histFile);
Expand All @@ -217,7 +216,7 @@ public NShell(NShellConfiguration configuration) {
.error(ex)
.log(NMsg.ofC("error resolving history file %s", this.history.getHistoryFile()));
}
NEnvs.of().setProperty(NShellHistory.class.getName(), this.history);
NWorkspace.get().setProperty(NShellHistory.class.getName(), this.history);
}
}

Expand Down Expand Up @@ -673,7 +672,7 @@ protected void executeInteractive(NShellContext context) {
NSystemTerminal.enableRichTerm();
NPath appVarFolder = NApp.of().getVarFolder();
if (appVarFolder == null) {
appVarFolder = NLocations.of().getStoreLocation(
appVarFolder = NWorkspace.get().getStoreLocation(
NId.of("net.thevpc.app.nuts.toolbox:nsh").get()
, NStoreType.VAR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* <br>
* ====================================================================
*/
package net.thevpc.nuts.env;
package net.thevpc.nuts;

import net.thevpc.nuts.reserved.NReservedUtils;
import net.thevpc.nuts.util.NBlankable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
package net.thevpc.nuts;

import net.thevpc.nuts.boot.reserved.util.NBootStringUtils;
import net.thevpc.nuts.env.NEnvCondition;
import net.thevpc.nuts.reserved.NReservedLangUtils;
import net.thevpc.nuts.reserved.NReservedUtils;
import net.thevpc.nuts.util.NBlankable;
Expand Down
1 change: 0 additions & 1 deletion core/nuts-api/src/main/java/net/thevpc/nuts/NApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.cmdline.NCmdLineAutoComplete;
import net.thevpc.nuts.cmdline.NCmdLineRunner;
import net.thevpc.nuts.env.NStoreType;
import net.thevpc.nuts.ext.NExtensions;
import net.thevpc.nuts.io.NPath;
import net.thevpc.nuts.spi.NComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
package net.thevpc.nuts;

import net.thevpc.nuts.env.NStoreType;
import net.thevpc.nuts.io.NPath;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
package net.thevpc.nuts;

import net.thevpc.nuts.env.NBootManager;

import net.thevpc.nuts.reserved.NApiUtilsRPI;
import net.thevpc.nuts.time.NClock;
import net.thevpc.nuts.log.NLog;
Expand Down Expand Up @@ -195,8 +195,7 @@ public static void runApplication(NApplication applicationInstance) {
return;
}
ws.runWith(() -> {
NSession session = NSession.of().get();
boolean inherited = NBootManager.of().getBootOptions().getInherited().orElse(false);
boolean inherited = NWorkspace.get().getBootOptions().getInherited().orElse(false);
NLog.of(NApplications.class).with().level(Level.FINE).verb(NLogVerb.START)
.log(
NMsg.ofC(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* governing permissions and limitations under the License.
* <br> ====================================================================
*/
package net.thevpc.nuts.env;
package net.thevpc.nuts;

import net.thevpc.nuts.util.NEnum;
import net.thevpc.nuts.util.NEnumUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package net.thevpc.nuts.env;
package net.thevpc.nuts;

import net.thevpc.nuts.*;
import net.thevpc.nuts.boot.NBootOptionsBoot;
import net.thevpc.nuts.boot.NBootWorkspaceFactory;
import net.thevpc.nuts.boot.NBootClassLoaderNode;
import net.thevpc.nuts.boot.NBootDescriptor;
import net.thevpc.nuts.cmdline.NCmdLine;
import net.thevpc.nuts.format.NContentType;
Expand All @@ -27,11 +25,11 @@ public interface NBootOptions {

NOptional<String> getBootRepositories();

NOptional<NBootClassLoaderNode> getRuntimeBootDependencyNode();
NOptional<NClassLoaderNode> getRuntimeBootDependencyNode();

NOptional<List<NBootDescriptor>> getExtensionBootDescriptors();

NOptional<List<NBootClassLoaderNode>> getExtensionBootDependencyNodes();
NOptional<List<NClassLoaderNode>> getExtensionBootDependencyNodes();

NOptional<NBootWorkspaceFactory> getBootWorkspaceFactory();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package net.thevpc.nuts.env;
package net.thevpc.nuts;

import net.thevpc.nuts.*;
import net.thevpc.nuts.boot.NBootWorkspaceFactory;
import net.thevpc.nuts.boot.NBootClassLoaderNode;
import net.thevpc.nuts.boot.NBootDescriptor;
import net.thevpc.nuts.ext.NExtensions;
import net.thevpc.nuts.format.NContentType;
Expand Down Expand Up @@ -33,11 +31,11 @@ static NBootOptionsBuilder of(){

NBootOptionsBuilder setBootRepositories(String bootRepositories);

NBootOptionsBuilder setRuntimeBootDependencyNode(NBootClassLoaderNode runtimeBootDependencyNode);
NBootOptionsBuilder setRuntimeBootDependencyNode(NClassLoaderNode runtimeBootDependencyNode);

NBootOptionsBuilder setExtensionBootDescriptors(List<NBootDescriptor> extensionBootDescriptors);

NBootOptionsBuilder setExtensionBootDependencyNodes(List<NBootClassLoaderNode> extensionBootDependencyNodes);
NBootOptionsBuilder setExtensionBootDependencyNodes(List<NClassLoaderNode> extensionBootDependencyNodes);

NBootOptionsBuilder setBootWorkspaceFactory(NBootWorkspaceFactory bootWorkspaceFactory);

Expand Down
Loading

0 comments on commit 72c4b8b

Please sign in to comment.