Commit 7cb70066 authored by Marc Coiffier's avatar Marc Coiffier
Browse files

Update the Curly documentation, in various places

parent 223ff400
No preview for this file type
......@@ -15,7 +15,7 @@ If you're feeling lucky, you can try to run the following command in a
terminal, which will perform all the necessary steps for you :
~~~~{.terminal}
curl -s https://www.curly-lang.org/install-curly.sh | sh -s - --prefix="$HOME/.local" --bin-dir="$HOME/.bin"
curl -s https://www.curly-lang.org/install-curly.sh | sh -s - --import-standard-keys
~~~~~
Compiling from source, for the curious
......
#!/bin/sh
curly_version="0.59.4.1"
curly_version="0.59.4.2"
curly_url="https://www.curly-lang.org/pkg/curly-$curly_version.tar.xz"
import_stdkeys=
install_dir=
prefix_dir="$HOME/.local"
lib_dir=
bin_dir=
while [ "$#" -gt 0 ]; do
......@@ -17,16 +18,21 @@ while [ "$#" -gt 0 ]; do
esac
case "$optname" in
--import-standard-keys) import_stdkeys=true;;
-p|--prefix) install_dir="$optval";;
-p|--prefix) prefix_dir="$optval";;
-L|--lib-dir) lib_dir="$optval";;
-B|--bin-dir) bin_dir="$optval";;
esac
done
if [ "${install_dir:+x}" = '' ]; then
read -p "Please enter a directory in which to install Curly (default: $HOME/.local/lib) : " install_dir </dev/tty
if [ "${lib_dir:+x}" = '' ]; then
read -p "Please enter a directory in which to install Curly (default: $prefix_dir/lib) : " lib_dir </dev/tty
fi
if [ "${install_dir:+x}" = '' ]; then
install_dir="$HOME/.local/lib"
if [ "${lib_dir:+x}" = '' ]; then
lib_dir="$prefix_dir/lib"
fi
if [ "${bin_dir:+x}" = '' ]; then
bin_dir="$prefix_dir/bin"
fi
trace() { printf "\033[1m$ %s \033[m" "$*" >&2; "$@"; ret="$?"; echo >&2; return $ret; }
......@@ -39,11 +45,9 @@ else
get_url() { exit 1; }
fi
get_url "$curly_url" | { mkdir -p "$install_dir"; trace tar -xJ --checkpoint=40 --checkpoint-action=dot -C "$install_dir"; }
if [ -n "$bin_dir" ]; then
mkdir -p "$bin_dir"
trace ln -fs "$install_dir/curly-$curly_version/curly" "$bin_dir/curly"
fi
get_url "$curly_url" | { mkdir -p "$lib_dir"; trace tar -xJ --checkpoint=40 --checkpoint-action=dot -C "$lib_dir"; }
mkdir -p "$bin_dir"
trace ln -fs "$lib_dir/curly-$curly_version/curly" "$bin_dir/curly"
if [ -n "$import_stdkeys" ]; then
"$bin_dir/curly" %'key import curly-std standard.curly-lang.org'
fi
{-# LANGUAGE CPP, ExistentialQuantification, ViewPatterns, RecursiveDo #-}
{-# LANGUAGE CPP, ExistentialQuantification, ViewPatterns, RecursiveDo, QuasiQuotes #-}
module Curly.Session.Commands.Navigation where
import Curly.Core
......@@ -13,11 +13,11 @@ import Curly.Style (setupTermFromEnv)
import Curly.UI.Options (symPath)
lsCmd,wdCmd,cdCmd,treeCmd :: Interactive Command
lsDoc = unlines [
"{section {title List Directory}"
,"{p {em Usage:} ls {em OR} ls PATH}"
,"{p List the contents of the working directory, or those of the relative path given on the command-line.}}"
]
lsDoc = [q_string|
{title List Directory}
{p {em Usage:} ls {em OR} ls PATH}
{p List the contents of the working directory, or those of the relative path given on the command-line.}
|]
lsCmd = withDoc lsDoc $ False <$ do
p <- hspace >> absPath ""
withMountain $ serveStrLn $
......@@ -26,23 +26,22 @@ lsCmd = withDoc lsDoc $ False <$ do
else let ModDir mod = fold (c'list $ localContext^??atMs p.t'Join)
in intercalate " " (c'set $ fromKList (fst<$>mod))
treeDoc = unlines [
"{section {title Show Directory Tree}"
,"{p {em Usage:} tree {em OR} tree PATH}"
,"{p Recursively list the contents of the working directory, or those of the relative path given on the command-line.}}"
]
treeDoc = [q_string|
{title Show Directory Tree}
{p {em Usage:} tree {em OR} tree PATH}
{p Recursively list the contents of the working directory, or those of the relative path given on the command-line.}
|]
treeCmd = withDoc treeDoc $ False <$ do
p <- hspace >> absPath ""
term <- liftIO setupTermFromEnv
withStyle $ withMountain $ serveStrLn . docString term ?style . document . map fst . Join . fold . c'list $ (localContext^??atMs p.t'Join)
cdDoc = unlines [
"{section {title Change Directory}"
,"{p {em Usage:} cd {em OR} cd PATH} "
,"{p "
," Set the working directory to the path given on the command-line. "
," Paths are taken relative to the working directory before changing.}}"
]
cdDoc = [q_string|
{title Change Directory}
{p {em Usage:} cd {em OR} cd PATH}
{p Set the working directory to the path given on the command-line.
Paths are taken relative to the working directory before changing.}
|]
cdCmd = withDoc cdDoc (fill False $ withargs <+? noarg)
where noarg = liftIO (modifyIORef ?sessionState (wd %- []))
withargs = nbhspace >> do
......@@ -54,5 +53,5 @@ cdCmd = withDoc cdDoc (fill False $ withargs <+? noarg)
else serveStrLn $ if has (each.t'Pure) m
then "Error: "+showPath newpath+" is a function"
else "Error: there is nothing under "+showPath newpath
wdDoc = "{section {title Print Working Directory} Prints the working directory}"
wdDoc = [q_string|{title Print Working Directory} {p Prints the working directory}|]
wdCmd = withDoc wdDoc $ False <$ (getSession wd >>= serveStrLn . showPath)
{-# LANGUAGE CPP, ExistentialQuantification, ViewPatterns, RecursiveDo #-}
{-# LANGUAGE CPP, ExistentialQuantification, ViewPatterns, RecursiveDo, QuasiQuotes #-}
module Curly.Session.Commands.Query where
import Curly.Core
......@@ -40,11 +40,11 @@ viewCmd doc onExpr onPath showV = withDoc doc . fill False $ (several "'s" >> vi
Just s -> showV [] s
_ -> serveStrLn $ "Error: "+n+": no such symbol."
editDoc = unlines [
"{section {title Edit Function}"
,"{p {em Usage:} edit PATH}"
,"{p Start an editing session for the function at PATH.}}"
]
editDoc = [q_string|
{title Edit Function}
{p {em Usage:} edit PATH}
{p Start an editing session for the function at PATH.}
|]
editCmd = viewCmd editDoc zero onPath $ \path (by leafPos -> r) -> case r of
SourceRange (Just f) (_,l,c) _ -> editSource f (l,c) reloadMountain
_ -> serveStrLn $ "No source position available for "+showPath path
......@@ -65,11 +65,12 @@ showExprDefault pat n v = do
serveStrLn (docString ?terminal ?style (fromMaybe (nodoc $ "Cannot show pattern "+showRawDoc pat)
(evalDocWithPatterns ?patterns params pat)))
showDoc = unlines [
"{section {title Formatted Query} {p {em Usage:} show (PATH|\\\\(EXPR\\\\)) [PATTERN]}",
" {p Show information about functions under PATH, or an ad-hoc expression}",
" {p The pattern will default to '\\{call show-default\\}' if left unspecified.}}"
]
showDoc = [q_string|
{title Formatted Query}
{p {em Usage:} show (PATH|\\(EXPR\\)) [PATTERN]}
{p Show information about functions under PATH, or an ad-hoc expression.}
{p The pattern will default to '\{call show-default\}' if left unspecified.}
|]
showCmd = withDoc showDoc . fill False $ do
epath <- map Right (nbhspace >> between (single '(') (single ')') (withParsedString (expr AnySpaces)))
<+? map Left ((nbhspace >> ((several "{}" >> getSession wd) <+? absPath ""))
......@@ -100,10 +101,12 @@ showCmd = withDoc showDoc . fill False $ do
Right (n,e) -> do
v <- optExprIn <$> getSession this <*> pure e
showExprDefault pat n v
patternDoc = unlines [
"{section {title Define Formatting Patterns} {p {em Usage:} pattern NAME ARG... = PATTERN {em OR} pattern NAME}",
" {p Defines a new query pattern accessible with \\{pattern PATTERN PARAM...\\}}",
" {p If you only specify the pattern name, its current definition will be printed instead.}}"]
patternDoc = [q_string|
{title Define Formatting Patterns}
{p {em Usage:} pattern NAME ARG... = PATTERN {em OR} pattern NAME}
{p Defines a new query pattern accessible with \{pattern PATTERN PARAM...\}}
{p If you only specify the pattern name, its current definition will be printed instead.}
|]
patternCmd = withDoc patternDoc . fill False $ do
ph:pt <- many1' (nbhspace >> dirArg <*= guard . (/="="))
let setPat = do
......
{-# LANGUAGE CPP, ExistentialQuantification, ViewPatterns, RecursiveDo #-}
{-# LANGUAGE CPP, ExistentialQuantification, ViewPatterns, RecursiveDo, QuasiQuotes #-}
module Curly.Session.Commands.Repository where
import Curly.Core
......@@ -19,35 +19,43 @@ import Data.IORef
repositoryCmd :: Interactive Command
repositoryDoc = unlines [
"{section {title Manage Repository}",
" {p A command to manage repositories and their contents}",
" {title Usage}",
ul [
li "{em repository info} {p List all active repositories}",
li "{em repository add <repository>} {p Add a repository to the list of active repositories}",
li "{em repository browse (<library-id>|<search-pattern>)} {p Open a sub-session in the context of an external library}",
li (fold ["{em repository list [<template> [<key-name> [<branch>]]]} ",
"{p List the branches published by <key-name>}",
"{ln If a branch name is specified, lists that branch's libraries instead.}"]),
li (fold ["{em repository commit <branch> <modifier>...}",
"{p Push a new commit on the given branch, by applying various modifiers in order}",
"{p The <modifier>s can be either of the following: ",
" {ul {li {em -add <path>...} Adds the libraries under <path> to the branch}",
" {li {em -(keep|drop) (<library-id>|<search-pattern>|(maximum|minimum) <template> by <template>)} ",
" {ln Filters the branch according to a pattern.}}}}"]),
li (fold ["{em repository branch <branch> ((fork|alias) <key-name> <source-branch>|rename <new-name>|delete)}",
"{p Create a new branch that points to the same commit a another.}",
"{p The 'alias' option creates an alias branch rather than a fork.",
" Alias branches will always be resolved to the latest commit on their source branch.}"]),
li (fold ["{em repository get (source|library) <filename> (#<library-id>|<search-pattern>)}",
" {p Retrieve a library or its source and saves it to a file}"]),
li (fold ["{em repository checkout <source-prefix> (#<library-id>|<search-pattern>)}",
"{p Reconstruct a working source tree for the given library}"])
],
"}"]
where li = format "{li.p %s}"
ul l = format "{ul %s}" (intercalate " " l)
repositoryDoc = [q_string|
{title Manage Repository}
{p A command to manage repositories and their contents.}
{title Usage}
{ul
{li.p {em repository info} {p List all active repositories}}
{li.p {em repository add <repository>} {p Add a repository to the list of active repositories}}
{li.p
{em repository browse (<library-id>|<search-pattern>)}
{p Open a sub-session in the context of an external library}}
{li.p
{em repository list [<template> [<key-name> [<branch>]]]}
{p List the branches published by <key-name>}
{ln If a branch name is specified, lists that branch's libraries instead.}}
{li.p
{em repository commit <branch> <modifier>...}
{p Push a new commit on the given branch, by applying various modifiers in order}
{p The <modifier>s can be either of the following:
{ul {li {em -add <path>...} Adds the libraries under <path> to the branch}
{li {em -(keep|drop) (<library-id>|<search-pattern>|(maximum|minimum) <template> by <template>)}
{ln Filters the branch according to a pattern.}}}}}
{li.p
{em repository branch <branch> ((fork|alias) <key-name> <source-branch>|rename <new-name>|delete)}
{p Create a new branch that points to the same commit a another.}
{p The 'alias' option creates an alias branch rather than a fork.
Alias branches will always be resolved to the latest commit on their source branch.}}
{li.p
{em repository get (source|library) <filename> (#<library-id>|<search-pattern>)}
{p Retrieve a library or its source and saves it to a file}}
{li.p
{em repository checkout <source-prefix> (#<library-id>|<search-pattern>)}
{p Reconstruct a working source tree for the given library}}}
|]
repositoryCmd = withDoc repositoryDoc $ False <$ do
cmd <- expected "keyword, either 'commit', 'list' or 'get-source'" (nbhspace >> dirArg)
u <- lookup curlyPublisher <$> getKeyStore
......
{-# LANGUAGE CPP, ExistentialQuantification, ViewPatterns, RecursiveDo #-}
{-# LANGUAGE CPP, ExistentialQuantification, ViewPatterns, RecursiveDo, QuasiQuotes #-}
module Curly.Session.Commands.Style where
import Curly.Core.Parser
......@@ -10,12 +10,12 @@ import Curly.Session.Commands.Common
styleCmd :: Interactive Command
styleDoc = unlines [
"{section {title Style Documentation}",
"{p {em Usage:} style TAG STYLE VALUE}",
"{p Changes the style of the given class of tags to match the value when showing documentation.}",
"{p {em Example:} style title color ff0000}}"
]
styleDoc = [q_string|
{title Style Documentation}
{p {em Usage:} style TAG STYLE VALUE}
{p Changes the style of the given class of tags to match the value when showing documentation.}
{p {em Example:} style title color ff0000}
|]
styleCmd = withDoc styleDoc $ False <$ do
tag <- nbsp >> dirArg
let hexColor = do
......
......@@ -71,7 +71,7 @@ EOF
tmp="$(mktemp -d)"
mkdir -p "$tmp/$full"
cd "$stack_path"
cp -r bin/$exe share/*/$exe-*/* "$tmp/$full"
cp -r bin/$exe share/*/$full/* "$tmp/$full"
tar -C "$tmp" -c .
rm -r "$tmp"
) | xz > public/pkg/$full.tar.xz
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment