From 43704cef769ae198f8eec8b14d42f68ae1087ed7 Mon Sep 17 00:00:00 2001 From: alexcoder04 Date: Sat, 9 Jul 2022 15:09:16 +0200 Subject: [PATCH] update for the new API --- .gitignore | 2 +- basename.cs | 11 ++++++----- cat.cs | 11 ++++++----- clear.cs | 7 ++++--- date.cs | 7 ++++--- echo.cs | 11 ++++++----- hostname.cs | 7 ++++--- manifest.apkg.json => manifest.json | 6 ++++-- printenv.cs | 7 ++++--- sleep.cs | 11 ++++++----- yes.cs | 11 ++++++----- 11 files changed, 51 insertions(+), 40 deletions(-) rename manifest.apkg.json => manifest.json (80%) diff --git a/.gitignore b/.gitignore index 7b65ad6..f46f11d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ bin Debug obj -*.lcpkg +*.lcp diff --git a/basename.cs b/basename.cs index 2b0219b..bd4acc8 100644 --- a/basename.cs +++ b/basename.cs @@ -7,15 +7,16 @@ namespace LeoConsole_ExamplePlugin { public class Basename : ICommand { public string Name { get { return "basename"; } } public string Description { get { return "print name with any leading directory components removed"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { - if (_InputProperties.Length < 2) { + if (_Arguments.Length < 2) { Console.WriteLine("you need to provide an argument"); return; } - Console.WriteLine(Path.GetFileName(_InputProperties[1])); + Console.WriteLine(Path.GetFileName(_Arguments[1])); } } } diff --git a/cat.cs b/cat.cs index 3aea2db..a850015 100644 --- a/cat.cs +++ b/cat.cs @@ -7,16 +7,17 @@ namespace LeoConsole_ExamplePlugin { public class Cat : ICommand { public string Name { get { return "cat"; } } public string Description { get { return "print contents of a file"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { - if (_InputProperties.Length < 2) { + if (_Arguments.Length < 2) { Console.WriteLine("you need to provide an argument"); return; } try { - Console.WriteLine(File.ReadAllText(_InputProperties[1])); + Console.WriteLine(File.ReadAllText(_Arguments[1])); } catch (Exception e) { Console.WriteLine("error: " + e.Message); } diff --git a/clear.cs b/clear.cs index 6c1f869..101ee41 100644 --- a/clear.cs +++ b/clear.cs @@ -7,9 +7,10 @@ namespace LeoConsole_ExamplePlugin { public class Clear : ICommand { public string Name { get { return "clear"; } } public string Description { get { return "clear the screen"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { Console.Clear(); } diff --git a/date.cs b/date.cs index f3f798a..ef32038 100644 --- a/date.cs +++ b/date.cs @@ -7,9 +7,10 @@ namespace LeoConsole_ExamplePlugin { public class Date : ICommand { public string Name { get { return "date"; } } public string Description { get { return "print current date and time"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { Console.WriteLine(DateTime.Now.ToString()); diff --git a/echo.cs b/echo.cs index 9639520..8708a6c 100644 --- a/echo.cs +++ b/echo.cs @@ -7,12 +7,13 @@ namespace LeoConsole_ExamplePlugin { public class Echo : ICommand { public string Name { get { return "echo"; } } public string Description { get { return "print the given parameters to the screen"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { - for (int i = 1; i < _InputProperties.Length; i++) { - Console.Write(InputProperties[i] + " "); + for (int i = 1; i < _Arguments.Length; i++) { + Console.Write(Arguments[i] + " "); } Console.Write("\n"); } diff --git a/hostname.cs b/hostname.cs index 2129ce2..9e5b072 100644 --- a/hostname.cs +++ b/hostname.cs @@ -8,9 +8,10 @@ namespace LeoConsole_ExamplePlugin { public class Hostname : ICommand { public string Name { get { return "hostname"; } } public string Description { get { return "print computer's hostname"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { Console.WriteLine(Dns.GetHostName()); diff --git a/manifest.apkg.json b/manifest.json similarity index 80% rename from manifest.apkg.json rename to manifest.json index e0e82cd..e461eb0 100644 --- a/manifest.apkg.json +++ b/manifest.json @@ -1,7 +1,9 @@ { - "manifestVersion": 2.1, + "manifestVersion": 3.0, "packageName": "coreutils", - "packageVersion": "0.2.0", + "packageVersion": "0.3.0", + "depends": [], + "compatibleVersions": ["2.0.0"], "build": { "command": "dotnet", "args": ["build", "--nologo"], diff --git a/printenv.cs b/printenv.cs index 39d0fe7..327fc66 100644 --- a/printenv.cs +++ b/printenv.cs @@ -8,9 +8,10 @@ namespace LeoConsole_ExamplePlugin { public class Printenv : ICommand { public string Name { get { return "printenv"; } } public string Description { get { return "print the environment"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { foreach (DictionaryEntry de in Environment.GetEnvironmentVariables()) { Console.WriteLine("{0}={1}", de.Key, de.Value); diff --git a/sleep.cs b/sleep.cs index 0b7a7ce..d872dc1 100644 --- a/sleep.cs +++ b/sleep.cs @@ -8,17 +8,18 @@ namespace LeoConsole_ExamplePlugin { public class Sleep : ICommand { public string Name { get { return "sleep"; } } public string Description { get { return "do nothing for given number of seconds"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { int dur; - if (_InputProperties.Length < 2) { + if (_Arguments.Length < 2) { dur = 1; } else { try { - dur = Int32.Parse(_InputProperties[1]); + dur = Int32.Parse(_Arguments[1]); } catch (Exception e) { Console.WriteLine("invalid number provided"); return; diff --git a/yes.cs b/yes.cs index 83714e0..5c8b488 100644 --- a/yes.cs +++ b/yes.cs @@ -7,15 +7,16 @@ namespace LeoConsole_ExamplePlugin { public class Yes : ICommand { public string Name { get { return "yes"; } } public string Description { get { return "output a string repeatedly until killed"; } } - public Action CommandFunktion { get { return () => Command(); } } - private string[] _InputProperties; - public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } } + public Action CommandFunction { get { return () => Command(); } } + public Action HelpFunction { get { return () => Console.WriteLine("not available"); } } + private string[] _Arguments; + public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } } public void Command() { string str; - if (_InputProperties.Length < 2) { + if (_Arguments.Length < 2) { str = "y"; } else { - str = _InputProperties[1]; + str = _Arguments[1]; } while (true) { Console.WriteLine(str);