summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJosé Eduardo <josee.edumont@gmail.com>2020-10-03 16:43:00 -0300
committerDavid Peter <sharkdp@users.noreply.github.com>2020-10-03 22:33:44 +0200
commit29b6ba07585ddf7553ae4468a7eb8014818afb25 (patch)
tree28e74517be208d52f7753e800324f4e15de02669 /tests
parentca5793dbea60d7b11643a508b618ca7a4fb11e9e (diff)
Added Elixir file example
Diffstat (limited to 'tests')
-rw-r--r--tests/syntax-tests/highlighted/Elixir/command.ex31
-rw-r--r--tests/syntax-tests/source/Elixir/LICENSE.md21
-rw-r--r--tests/syntax-tests/source/Elixir/command.ex31
3 files changed, 83 insertions, 0 deletions
diff --git a/tests/syntax-tests/highlighted/Elixir/command.ex b/tests/syntax-tests/highlighted/Elixir/command.ex
new file mode 100644
index 00000000..c6c9d07b
--- /dev/null
+++ b/tests/syntax-tests/highlighted/Elixir/command.ex
@@ -0,0 +1,31 @@
+defmodule Charlex.Command do
+ @callback usage() :: [String.t()]
+
+ @callback description() :: String.t()
+
+ @callback parse_args(args :: String.t()) :: any()
+
+ @callback run(context :: Map.t(), args :: [String.t()] | any()) :: String.t() | any()
+
+ @optional_callbacks usage: 0, description: 0, parse_args: 1
+
+ defmacro __using__(_opts) do
+ quote do
+ @behaviour unquote(__MODULE__)
+
+ @impl true
+ def usage, do: "This command is without usage, will add it soon"
+
+ @impl true
+ def description, do: "This command is without description, will add it soon"
+
+ @impl true
+ def run(_context, _args), do: :ok
+
+ @impl true
+ def parse_args(args), do: args |> String.split() |> Kernel.tl()
+
+ defoverridable parse_args: 1, description: 0, run: 2, usage: 0
+ end
+ end
+end
diff --git a/tests/syntax-tests/source/Elixir/LICENSE.md b/tests/syntax-tests/source/Elixir/LICENSE.md
new file mode 100644
index 00000000..668451f8
--- /dev/null
+++ b/tests/syntax-tests/source/Elixir/LICENSE.md
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 José Eduardo
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/tests/syntax-tests/source/Elixir/command.ex b/tests/syntax-tests/source/Elixir/command.ex
new file mode 100644
index 00000000..48d6463f
--- /dev/null
+++ b/tests/syntax-tests/source/Elixir/command.ex
@@ -0,0 +1,31 @@
+defmodule Charlex.Command do
+ @callback usage() :: [String.t()]
+
+ @callback description() :: String.t()
+
+ @callback parse_args(args :: String.t()) :: any()
+
+ @callback run(context :: Map.t(), args :: [String.t()] | any()) :: String.t() | any()
+
+ @optional_callbacks usage: 0, description: 0, parse_args: 1
+
+ defmacro __using__(_opts) do
+ quote do
+ @behaviour unquote(__MODULE__)
+
+ @impl true
+ def usage, do: "This command is without usage, will add it soon"
+
+ @impl true
+ def description, do: "This command is without description, will add it soon"
+
+ @impl true
+ def run(_context, _args), do: :ok
+
+ @impl true
+ def parse_args(args), do: args |> String.split() |> Kernel.tl()
+
+ defoverridable parse_args: 1, description: 0, run: 2, usage: 0
+ end
+ end
+end