Added storage classes - work in progress IV
This commit is contained in:
parent
2e9a1efd23
commit
c4f577a701
@ -56,7 +56,7 @@ configure(subprojects - project(':android')) {
|
||||
}
|
||||
|
||||
subprojects {
|
||||
version = '1.0.0'
|
||||
version = '0.0.0-SNAPSHOT'
|
||||
ext.appName = 'open-eggbert'
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -17,6 +17,7 @@ dependencies {
|
||||
api "com.github.tommyettinger:libgdx-utils:$utilsVersion"
|
||||
api "de.golfgl.gdxcontrollerutils:gdx-controllerutils-mapping:$controllerMappingVersion"
|
||||
api "games.rednblack.miniaudio:miniaudio:$miniaudioVersion"
|
||||
api "com.openeggbert.gdx:gdx-storage:0.0.0-SNAPSHOT"
|
||||
annotationProcessor "org.projectlombok:lombok:$lombokVersion"
|
||||
compileOnly "org.projectlombok:lombok:$lombokVersion"
|
||||
testImplementation "org.junit.jupiter:junit-jupiter-api:5.10.3"
|
||||
@ -26,4 +27,4 @@ dependencies {
|
||||
test {
|
||||
useJUnitPlatform {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging.storage;
|
||||
package com.openeggbert.storage.filesystem.command;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
@ -0,0 +1,29 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.storage.filesystem.command;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public interface CommandLineScanner {
|
||||
String nextLine();
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging.storage;
|
||||
package com.openeggbert.storage.filesystem.command;
|
||||
|
||||
/**
|
||||
*
|
@ -17,13 +17,12 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging.storage;
|
||||
package com.openeggbert.storage.filesystem.command;
|
||||
|
||||
import com.openeggbert.storage.Storage;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
@ -49,11 +48,14 @@ public class StorageCommandLine {
|
||||
}
|
||||
|
||||
private String extractArgument(String arguments, int argumentIndex) {
|
||||
if(arguments.isEmpty()) {
|
||||
return arguments;
|
||||
}
|
||||
String[] array = arguments.split(" ");
|
||||
if (argumentIndex > (array.length - 1)) {
|
||||
if (argumentIndex > (array.length)) {
|
||||
return "";
|
||||
}
|
||||
return array[argumentIndex];
|
||||
return array[argumentIndex + 1];
|
||||
}
|
||||
|
||||
public StorageCommandLine(String userIn, String hostnameIn, Storage storageIn) {
|
||||
@ -62,21 +64,23 @@ public class StorageCommandLine {
|
||||
this.hostname = hostnameIn;
|
||||
this.storage = storageIn;
|
||||
|
||||
addCommand("date", arguments -> provideOutput(result -> result.setOutput(new Date().toString())));
|
||||
addCommand("whoami", arguments -> provideOutput(result -> result.setOutput(user)));
|
||||
addCommand("uptime", arguments -> provideOutput(result
|
||||
-> result.setOutput(
|
||||
LocalDateTime.now().toString().replace("T", " ").substring(10, 19) + " up "
|
||||
new Date().toString().substring(11, 19) + " up "
|
||||
+ (System.nanoTime() - startNanoTime) / 1000000000l / 60l
|
||||
+ " minutes"
|
||||
+ ", 1 user"
|
||||
)));
|
||||
|
||||
addCommand("hostname", arguments -> provideOutput(result -> result.setOutput(hostname)));
|
||||
addCommand("test", arguments-> provideOutput(result-> result.setOutput((extractArgument(arguments, 0)))));
|
||||
addCommand("uname", arguments -> provideOutput(result -> result.setOutput(
|
||||
"LinuxBashCommandLinePartialEmulation"
|
||||
+ ((extractArgument(arguments, 0).equals("-a"))
|
||||
? (hostname + " 0.0.0 ("
|
||||
+ LocalDateTime.now().toString().replace("T", " ").substring(0, 10) + ")")
|
||||
+ new Date().toString() + ")")
|
||||
: "")
|
||||
)));
|
||||
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging.storage;
|
||||
package com.openeggbert.storage.filesystem.command;
|
||||
|
||||
import com.openeggbert.storage.map.MemoryStorage;
|
||||
import java.util.Scanner;
|
||||
@ -28,17 +28,7 @@ import java.util.Scanner;
|
||||
*/
|
||||
public class StorageCommandLineScanner {
|
||||
|
||||
private StorageCommandLineScanner() {
|
||||
//Not meant to be instantiated.
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MemoryStorage memoryStorage = new MemoryStorage();
|
||||
final String user = "player";
|
||||
final String hostname = "openegggbert";
|
||||
|
||||
StorageCommandLine storageCommandLine = new StorageCommandLine(user, hostname, memoryStorage);
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
public StorageCommandLineScanner(StorageCommandLine storageCommandLine, CommandLineScanner scanner) {
|
||||
|
||||
while (true) {
|
||||
System.out.print(storageCommandLine.getCommandLineStart());
|
@ -17,7 +17,7 @@
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging.storage;
|
||||
package com.openeggbert.storage.filesystem.command;
|
||||
|
||||
/**
|
||||
*
|
@ -65,7 +65,7 @@ public class MapStorage implements Storage {
|
||||
|
||||
@Override
|
||||
public String cd(String path) {
|
||||
System.out.println("path="+path);
|
||||
// System.out.println("path="+path);
|
||||
String absolutePath = path.equals(TWO_DOTS) ? getParentPath(workingDirectory) : convertToAbsolutePathIfNeeded(path);
|
||||
|
||||
if (!exists(absolutePath)) {
|
||||
@ -122,7 +122,7 @@ public class MapStorage implements Storage {
|
||||
private static final String EIGHT_COLONS = "::::::::";
|
||||
|
||||
private static String getParentPath(String path) {
|
||||
System.out.println("getParentPath()");
|
||||
// System.out.println("getParentPath()");
|
||||
if (path == null) {
|
||||
throw new OpenEggbertException("Path is null");
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging.storage;
|
||||
|
||||
import com.openeggbert.storage.filesystem.command.CommandLineScanner;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class DesktopCommandLineScanner implements CommandLineScanner {
|
||||
|
||||
private final Scanner scanner;
|
||||
|
||||
public DesktopCommandLineScanner() {
|
||||
this.scanner = new Scanner(System.in);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String nextLine() {
|
||||
return scanner.nextLine();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Open Eggbert: Free recreation of the computer game Speedy Eggbert.
|
||||
// Copyright (C) 2024 the original author or authors.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation, either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see
|
||||
// <https://www.gnu.org/licenses/> or write to the Free Software
|
||||
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.openeggbert.lwjgl3.debugging.storage;
|
||||
|
||||
import com.openeggbert.storage.filesystem.command.StorageCommandLine;
|
||||
import com.openeggbert.storage.filesystem.command.StorageCommandLineScanner;
|
||||
import com.openeggbert.storage.map.MemoryStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author robertvokac
|
||||
*/
|
||||
public class DesktopStorageCommandLineScanner {
|
||||
|
||||
private DesktopStorageCommandLineScanner() {
|
||||
//Not meant to be instantiated.
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MemoryStorage memoryStorage = new MemoryStorage();
|
||||
final String user = "player";
|
||||
final String hostname = "openegggbert";
|
||||
StorageCommandLine storageCommandLine = new StorageCommandLine(user, hostname, memoryStorage);
|
||||
StorageCommandLineScanner storageCommandLineScanner = new StorageCommandLineScanner(
|
||||
storageCommandLine, new DesktopCommandLineScanner());
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user