summoner-tui: Tool for scaffolding fully configured batteries-included production-level Haskell projects using TUI.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

Tool for scaffolding fully configured batteries-included production-level Haskell projects using TUI. See README.md for details.


[Skip to Readme]

Properties

Versions 0.1.0, 0.1.0, 1.4.0.0, 2.0.0.0, 2.0.1.0, 2.0.1.1
Change log CHANGELOG.md
Dependencies base (>=4.10 && <4.13), base-noprelude (>=4.10 && <4.13), brick (>=0.47 && <0.48), directory (>=1.3.0.2 && <1.4), filepath (>=1.4.1.2 && <1.5), microlens (>=0.4 && <0.5), microlens-th (>=0.4 && <0.5), relude (>=0.5.0 && <0.6), summoner (>=1.3.0 && <1.4), summoner-tui, text (>=1.2.3.0 && <1.3), vty (>=5.25 && <5.26) [details]
License MPL-2.0
Copyright 2018-2019 Kowainik
Author Kowainik
Maintainer xrom.xkov@gmail.com
Category TUI, TUI Tool, Development
Home page https://github.com/kowainik/summoner
Bug tracker https://github.com/kowainik/summoner/issues
Source repo head: git clone git@github.com:kowainik/summoner.git
Uploaded by vrom911 at 2019-04-11T02:52:30Z

Modules

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for summoner-tui-0.1.0

[back to package description]

🔮 Summoner

wizard Build Windows build Hackage MPL-2.0 license

So many of our dreams at first seem impossible, then they seem improbable, and then, when we summon the will, they soon become inevitable.

Christopher Reeve

Summoner is a tool for scaffolding fully configured batteries-included production-level Haskell projects.

Do you want to create a library that is to be uploaded to Hackage/Stackage, that builds with both Cabal and Stack and supports the latest three major GHC versions? Or you are building a production application which uses a custom prelude and has CI with Travis Linux and AppVeyors Windows checks? Summoner can help you do all that with minimal effort from you - it can even upload the project to GitHub if you wish!

By the way, Summoner operates as either CLI or TUI application, so you can choose what you're more comfortable with and install only the required one.

Structure

Demo ↑

TUI demo ↑

TUI demo

CLI demo ↑

CLI demo

Scaffolded project structure ↑

This is an example of the project hierarchy you can get if you're running Summoner with all options enabled:

project-name/
├── app/
│   └── Main.hs
├── benchmark/
│   └── Main.hs
├── src/
│   ├── ProjectName.hs
│   └── Prelude.hs
├── test/
│   └── Spec.hs
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── project-name.cabal
├── README.md
├── Setup.hs
├── stack.yaml
├── appveyor.yml
├── .git
├── .gitignore
├── .stylish-haskell.yaml
└── .travis.yml

You can also see complete examples in the following folder:

Directory smallProject contains an example of the straightforward package, and fullProject shows a generated project with more advanced structure and more features.

Features ↑

Summoner is a tool that combines predefined configurations, command-line arguments and a chosen interface.

To fully understand the power in your hands with the help of Summoner, please check out this section.

Below you can see highlighted features in different categories.

Project ↑

GitHub ↑

CI ↑

Others ↑

Get started ↑

Prerequisites ↑

To start using Summoner make sure that you have the following tools installed on your machine:

Installation ↑

Summon contains two executables:

Below you can find the description of how to install each of them so you can choose the one you want.

Summon-TUI ↑

NOTE: summon-tui is not supported on Windows. See this issue.

TUI: download binary ↑

You can download binary directly from GitHub releases.

After downloading binary, make it executable and copy it under convenient location, for example:

chmod +x summon-cli-linux
mv summon-cli-linux ~/.local/bin/summon
TUI: from source ↑

Fetch the repo using cabal:

cabal get -s summoner

or clone the directory from GitHub:

git clone https://github.com/kowainik/summoner.git

Step into the directory:

cd summoner

Build and install using cabal:

cabal new-install summoner-tui:exe:summon-tui

Build and install using stack:

stack install summoner-tui:exe:summon-tui

Summon-CLI ↑

CLI: download binary ↑

You can download binary directly from GitHub releases.

After downloading binary, make it executable and copy it under convenient location, for example:

chmod +x summon-cli-linux
mv summon-cli-linux ~/.local/bin/summon
CLI: from Hackage/Stackage ↑

Using cabal:

cabal new-update
cabal new-install summoner

Using stack:

stack install summoner
CLI: from source ↑

Fetch the repo using cabal:

cabal get -s summoner

or clone the directory from GitHub:

git clone https://github.com/kowainik/summoner.git

Step into the directory:

cd summoner

Build and install using cabal:

cabal new-install summoner-cli:exe:summon

Build and install using stack:

stack install summoner:exe:summon

Setup ↑

You can turn on bash auto-completion by running the following command:

source <(summon --bash-completion-script `which summon`)

Usage ↑

To start summoning projects nothing additional is required. However, to tweak your settings further, you can use additional configuration settings. There are several options you can use to set particular configurations for new projects (in increasing order of priority):

  1. Default configuration file (~/.summoner.toml).
  2. Fields user.login, user.name and user.email from ~/.gitconfig.
  3. Explicitly specified configuration file by --file FILENAME option (used instead of the default one if specified).
  4. Options that are stated by CLI arguments.
  5. User input. It could be
    • TUI – User data specified in the window of summon-tui.
    • CLI – Interactively inputted answers during execution of the summon command (for the options that were not specified on previous steps).

To cut a long story short, the configuration uses Partial Options Monoid Pattern.

File configuration ↑

Here is the list of the options that can be configured to suit your needs. If options are not specified, they are asked interactively (or some sensible defaults are used).

Field Type Description
cabal Bool Add Cabal support?
stack Bool Add Stack support?
owner Text GitHub login.
fullName Text Full name.
email Text E-mail address.
license License One of: MIT, BSD2, BSD3, GPL-2, GPL-3, LGPL-2.1, LGPL-3, AGPL-3, Apache-2.0, MPL-2.0, None.
ghcVersions [GHC] summoner uses default GHC-8.6.4. However, additionally you can specify other versions. For each version x.y.z the stack-x.y.z.yaml will be created.
github Bool Turn on GitHub integration by default?
gitignore [Text] List of files you want added to the default .gitignore. (Ignored if github = false)
noUpload Bool Do not upload to GitHub, but create all GitHub related files if specified (Ignored if github = false)
private Bool Create private repository by default? (Ignored if github = false)
travis Bool Turn on Travis integration by default? (Ignored if github = false)
appveyor Bool Turn on AppVeyor integration by default? (Ignored if github = false)
lib Bool Create src folder with simple ProjectName.hs file and library target?
exe Bool Create app folder with simple Main.hs file and executable target?
test Bool Create test folder with simple Spec.hs file and test target?
bench Bool Create benchmark folder with Main.hs file with gauge library usage example?
extensions [Text] List of the default extensions to add into default-extensions section in the .cabal.
ghc-options [Text] List of the default GHC options to add into ghc-options section in the .cabal.
stylish.* Text stylish.file to provide the absolute file path OR stylish.url to download the .stylish-haskell.yaml file to use in the project.
contributing.* Text contributing.file to provide the absolute file path OR contributing.url download OR contribuint.link to link the CONTRIBUTING.md file to use in the project.
[prelude]
package Text The package name of the custom prelude you'd like to use in the project (doesn't work without module field).
module Text The module name of the custom prelude you'd like to use in the project (doesn't work without package field).

See the example of the configuration for projects of the Kowainik organization.

Command line arguments ↑

Available commands:

Usage:
  summon COMMAND
      Set up your own Haskell project

Available commands:
  new                      Create a new Haskell project
  script                   Create a new Haskell script
  show                     Show available licenses or ghc versions

Available global options:
  -h, --help               Show this help text
  -v, --version            Show summoner's version

summon new command: ↑

Usage:
  summon new PROJECT_NAME [--ignore-config] [--no-upload] [--offline]
             [-f|--file FILENAME]
             [--cabal]
             [--stack]
             [--prelude-package PACKAGE_NAME]
             [--prelude-module MODULE_NAME]
             [with    [OPTIONS]]
             [without [OPTIONS]]

Available options:
  -h, --help               Show this help text
  --ignore-config          Ignore configuration file
  --no-upload              Do not upload to GitHub. Special case of the '--offline' flag.
  --offline                Offline mode: create project with 'All Rights Reserved' license
                           and without uploading to GitHub.
  --cabal                  Cabal support for the project
  --stack                  Stack support for the project
  -f, --file FILENAME      Path to the toml file with configurations. If not
                           specified '~/.summoner.toml' will be used if present
  --prelude-package PACKAGE_NAME
                           Name for the package of the custom prelude to use in
                           the project
  --prelude-module MODULE_NAME
                           Name for the module of the custom prelude to use in
                           the project

Available commands:
  with                     Specify options to enable
  without                  Specify options to disable

Available command options:
  -h, --help               Show this help text
  -g, --github             Github integration
  -p, --private            Create private GitHub repository
  -c, --travis             Travis CI integration
  -w, --app-veyor          AppVeyor CI integration
  -l, --library            Library target
  -e, --exec               Executable target
  -t, --test               Tests
  -b, --benchmark          Benchmarks

summon script command: ↑

Usage:
  summon script BUILD_TOOL [-g|--ghc GHC_VERSION] [-n|--name FILE_NAME]
      Create a new Haskell script

Available options:
  -h,--help                Show this help text
  -g,--ghc GHC_VERSION     Version of the compiler to be used for script
  -n,--name FILE_NAME      Name of the script file

summon show command: ↑

Usage:
  summon show COMMAND
      Show supported licenses or ghc versions

Available commands:
  ghc                      Show available ghc versions
  license                  Show available licenses
  license [LICENSE_NAME]   Show specific license text

Available options:
  -h, --help               Show this help text

For example, the following command preconfigures the project settings with the custom prelude relude, included library, executable, test stanzas (but without benchmarks), creates a private repository on GitHub with the Travis CI and AppVeyor CI integrated.

summon new my-project with -letgcpw without -b --prelude-package relude --prelude-module Relude

TUI ↑

TUI new command ↑

summon new TUI

Section 1 – The main section where user inputs data or changes the configurations.

Section 2 – The structure of the project that is going to be created with the current configurations. This tree changes on-the-fly.

Section 3 – Hints, project status, or current errors in the configurations.

Section 4 – Useful hotkeys.

The TUI window opens with the pre-filled information received from a config file and command-line arguments. However, it's possible to change any field as per your needs.

In the screenshot you can see that you'll be given a few text fields to fill in or some checkboxes that represent boolean values of the configurations. To help you fill in the correct input, there are some ⓘ info messages in the Status section, which give additional details about the current field.

To help you navigate between the form fields here are the available hotkeys:

Key Action
Esc Abort summoner
Enter If input is valid go to the Confirm window
Tab Change the focus to the next active field
Shift + Tab Change the focus to the previous active field
Space Enable/disable current checkbox or radio button
Ctrl + d Delete the input of the current text field
Ctrl + u Delete the input of the current text field from the cursor position to the beginning
Ctrl + k Delete the input of the current text field from the cursor position to the end
Ctrl + a Move the cursor to the beginning of the current input field
Ctrl + e Move the cursor to the end of the current input field
Up/Down Scroll license list when focused

Note that the form should be valid in order to be able to go to the Confirm window. If there are some errors in the input, you could see details about these errors in the Status section of the form.

TUI script command ↑

See CLI description of the summon script command.

TUI show command ↑

These commands display the list of supported GHC versions or Licenses. Also, when the license name is specified the window with the scrollable content of the License text is shown.

CLI ↑

CLI new command ↑

In CLI mode of operation Summoner asks about every project setting. Most of the questions contain a default value, so you can press Enter to choose the default value. If some option is specified via a configuration file or CLI arguments, then the question is skipped and the predefined value is used.

CLI script command ↑

This command creates minimal cabal or stack script file which allows you to save some keystrokes and eliminates the need to remember magic words for scripts.

Cabal example: summon script cabal -n Main.hs generates executable file Main.hs with the following content:

#!/usr/bin/env cabal
{- cabal:
build-depends:
  , base ^>= 4.12.0.0
-}

main :: IO ()
main = putStrLn "Hello, World!"

Stack example: summon script stack -n Main.hs generates executable file Main.hs with the following content:

#!/usr/bin/env stack
{- stack
  --resolver lts-13.16
  script
  --package base
-}

main :: IO ()
main = putStrLn "Hello, World!"

CLI show command ↑

These commands display the list of supported GHC versions, or Licenses. Also, when the license name is specified, the content of the License is outputted to the terminal.

FAQ ↑

I want to use HTTPS remote for the created GitHub project, but it creates SSH one. How should I fix this?

We are using hub tool to create the projects at GitHub. It uses SSH so that you would get the remote links in the following format:

git@github.com:user/repo.git

We can not change or configure this behaviour, but there are several workarounds in case you need to use HTTPS link for the remote.

  1. Change the remote of the repository after its creation:
    git remote set-url origin https://github.com/user/repo.git
    
  2. Change hub configurations globally. Simply run the following command:
    git config --global hub.protocol https
    
  3. Alternatively, change hub configurations for a single session:
    export HUB_PROTOCOL="https"
    

For Developers ↑

If you'd like to take part in the development processes, here are a few things to keep in mind:

Dependencies ↑

On Linux, to build the summoner-tui you'll need to have libtinfo installed. The easiest way to get this is from your system's package manager and is usually available as the package libtinfo-dev.

Build ↑

To build the project you can use the following commands:

cabal new-build all

for Cabal and

stack build

for Stack.

Test ↑

Summoner uses the golden tests technique for assuring the correctness of the generated files. For this purpose, we have the golden folder with two sample projects to test against.

To actually run tests you need to run:

cabal new-test all

or

stack test

Run ↑

Building Summoner with the recommended method creates two executables: summon and summon-tui. To run the compiled executable you can use the following commands:

cabal new-exec summon -- SOME_COMMAND
cabal new-exec summon-tui -- SOME_COMMAND

or

stack exec summon -- SOME_COMMAND
stack exec summon-tui -- SOME_COMMAND

Changelog ↑

Each package has its own changelog:

Acknowledgments ↑

This project was inspired by Aelve/new-hs, which is the tool with the same goal but it's only for creating cabal projects.

Icons made by Nikita Golubev from Flaticon is licensed by CC 3.0 BY.