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