Skip to content

zoedsoupe/nexus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7c570c6 Β· Dec 5, 2024

History

28 Commits
Dec 5, 2024
Nov 17, 2024
Nov 17, 2024
Nov 17, 2024
Jun 15, 2023
Nov 17, 2024
Jan 14, 2024
Mar 25, 2023
Nov 17, 2024
Nov 17, 2024
Nov 17, 2024
Nov 17, 2024
Nov 17, 2024

Repository files navigation

Nexus

     _      __
|\ ||_\/| |(_
| \||_/\|_|__)

Create CLIs in a magic and declarative way!

An Elixir library to write command line apps in a cleaner and elegant way!

Hex.pm Downloads Documentation ci

Installation

Just add the nexus_cli package to your mix.exs

def deps do
  [
    {:nexus_cli, "~> 0.5"}
  ]
end

Example

defmodule MyCLI do
  @moduledoc "This will be used into as help"

  use Nexus.CLI

  defcommand :fizzbuzz do
    description "Plays fizzbuzz - this will also be used as help"

    value :integer, required: true
  end

  @impl Nexus.CLI
  def handle_input(:fizzbuzz, %{value: value}) when is_integer(value) do
    cond do
      rem(value, 3) == 0 and rem(value, 5) == 0 -> IO.puts("fizzbuzz")
      rem(value, 3) == 0 -> IO.puts("fizz")
      rem(value, 5) == 0 -> IO.puts("buzz")
      true -> IO.puts value
    end
  end
end

More different ways to use this library can be found on the examples folder Documentation on defining a CLI module can be found at the Nexus.CLI

Roadmap

Feature Status Description
Core Nexus.CLI Implementation βœ… Completed Base implementation of the Nexus.CLI module with macro-based DSL for defining CLIs.
Automatic Help Generation βœ… Completed Automatically generate help messages based on command definitions.
Command Parsing and Dispatching βœ… Completed Parse user input and dispatch commands to the appropriate handlers.
Nexus.TUI Development 🚧 In Progress Build the Nexus.TUI module leveraging Phoenix LiveView and TEA for terminal UIs.
TUI Component Library πŸ”œ Planned Develop reusable components for building terminal UIs.
Integration with Phoenix LiveView πŸ”œ Planned Integrate Nexus.TUI with Phoenix LiveView for live terminal experiences.
Community Contributions ♾️ Ongoing Encourage and incorporate feedback and contributions from the community.

Features

  • Macro based DSL
    • define global/root commands
    • define subcommands (supporting nesting)
    • define flags
    • define global/root flags
  • Automatic help flags generation

Why "Nexus"

Nexus is a connection from two different worlds! This library connects the world of CLIs with the magic world of Elixir!

Inspirations

Highly inspired in clap-rs