mirror of
https://github.com/sharkdp/bat.git
synced 2025-09-01 10:52:24 +01:00
Added Elixir file example
This commit is contained in:
committed by
David Peter
parent
ca5793dbea
commit
29b6ba0758
31
tests/syntax-tests/source/Elixir/command.ex
Normal file
31
tests/syntax-tests/source/Elixir/command.ex
Normal file
@@ -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
|
Reference in New Issue
Block a user