Next Generation Shell (NGS)
GPL-3.0 License
Bot releases are visible (Hide)
Iter(SubSeq)
=~(Eachable1, Pfx, MatchContext)
DecodeHints
=~(DecodeHints, ProcessesPipeline, MatchContext)
AtPath
patternResetPath
pattern=~(Any, Any, MatchContext)
which returns false
decode()
implementation for aws
command=~(Str, SubSeq, MatchContext)
in(Int, NumRange)
which was causing for i in 0 ...
to run once instead of not runningPublished by ilyash-b over 1 year ago
assert(Fun, Type, Str)
for asserting that the code throws the given exception. The type must be subtype of Exception.net
c_sockaddr
, c_sockaddr_un
, c_sockaddr_in
socket()
, bind()
, listen()
, accept()
, recvfrom()
, send()
SOCK_STREAM
, SOCK_DGRAM
, SOCK_RAW
, MSG_OOB
, MSG_PEEK
, MSG_WAITALL
(all prefixed with C_
)Not
type and support in pattern matchingenv:
option to pass environment when running external programsensure(Int, NumRange)
last(Eachable1, Any)
, the counterpart of first()skip(Iter, Any)
- skip elements matching the patternskip(Iter, Int)
- skip given number of elementsecho_cli()
AWS2::regions(CommandsPipeline, Arr)
IfExists
pattern for optionally present fieldsbefore_first(Str, Str)
- get the piece before first occurrence of the delimiterafter_last(Str, Str)
- get the piece after the last occurrence of the delimiterUndefinedUpVar
exception, thrown when accessing undefined "upvar"Error
, not Exception
: NotImplemented
, ReadFail
, RequireFail
, MainFail
x.HERE
and x::HERE
inspect()
regs
parameter to AWS2::regions(Fun)
$(log: ...)
can now take Str to prefix the messageretry()
loggingTime(Str)
is_subtype(Type, Type)
is now deprecated, use <=
operator, example: T1 <= T2
. Solves #391.typeof(Any)
is now deprecated, use Type(Any)
instead.x \ f
syntax is now deprecated, use x.f()
and x.{...}
instead.Published by ilyash-b over 2 years ago
curl -i ...
command into {"code": Int, "message": Str, "headers": Hash, "headers_arr": Hash, "body": Str}decode(Str, p)
, where p
is a Path
or its subtype.assert(Path)
Bool(Real)
native_ll_maybe_wrap
TmpDir
replace(File, Any, Any)
for in-place replacementgroup(Eachable1, Fun)
now has additional parameter v
: group(e:Eachable1, k:Fun, v:Fun=...)
. v
tells how to process values before adding to the resulting multi-value-map.?
operator now takes Any
instead of Fun
as the right argument.tr
exception when pattern is a Hash
and it should match not at the top level.Argv
now accepts Repeat
keys: {Repeat('--repeat'): my_arr}
my_arr[idx] = val
for negative idx
es.c_pcre_exec
now behaves correctly when too many captures are specifiedRegExp#options
.>${null}
.($())
is now a valid syntax for the identifier $()
Argv
- ['--repeat']
is deprecated in favor of Repeat('--repeat')
attrs()
is deprecated, use meta()
insteadStr(Path)
is now returning .path
, not <Path path=...>
the_one()
is now fixed and will throw exception instead of returning null when appropriate found_none
or found_more
is not specified.Published by ilyash almost 3 years ago
Hash(Hash)
(a no-op)PatternAction
type for combining a pattern and an action to take when there is a match->
syntax for constructing PatternAction
=~(x, PatternAction)
which checks the pattern and conditionally runs the actionMatchContext
typeDeep
type for deep data structure matchingHash(Eachable1)
- Issue #436 - Add Hash(array_of_key_value_pairs)exec()
methods - Issue #459partial()
is now deprecated because it's not usedLit
type to convey literal value, devoid of any "magical" meaningcollector(Stats, Fun)
debug(Str, Fun)
is now supportedensure(Arr, T)
for T
being subtype of ArrLike
fork()
, higher level wrapper around c_fork()
Str(ArrLike)
inspect()
fix for partially applied functions: ngs -pi 'X*2'
does not fail anymore.=~(x, Hash)
now supports patterns for keysENV
as default value for a parameter.inherit()
callsmost_by_cb()
Hash
keysexit_hook
now removes hooks in child fork()
.path
- f=TmpFile(); $(echo a > $f)
- Issue #490test.ngs
in the root folder now accepts optional file names; defaults to lang-tests.ngs
, stdlib.ngs
, and all *.ngs
files in lib/autoload
nofail:
optionwrite(f:File, s:Str)
now returns f
without(Eachable1, Any)
without(Eachable2, Any)
Published by organom about 3 years ago
Setup NGS in Github Action support
Published by ilyash over 3 years ago
replace(Str, RegExp, Str)
Bool(UserDefinedMethod)
c_pow(Real, Real)
, pow(Real, Real)
, pow(Int, Int)
decode()
for JSON Web Token (JWT)echo(File, Str)
echo(File, Lines)
C_DEFS
namespace for C define
d constants (currently only with _SC_NPROCESSORS_ONLN
but will add more later, issue #113)c_sysconf()
, sysconf()
CleanupPolicy
, KeepCleanupPolicy
, RemoveCleanupPolicy
, KeepOnErrorCleanupPolicy
to be used with TmpFile
TmpFile
now accepts optional CleanupPolicy
argument (defaults to RemoveCleanupPolicy
)ngs -e ...
, ngs -p ...
, etc - allow using _
instead of fetch()
.Str(File)
- now display correct type name for subtypesdecode_base64()
more roubstpmap(Eachable1, Fun)
now limits number of threads (issue #113)MaybeFile
TmpFile
is not expirimental anymoreencode_json()
with pretty=true
can now handle larger inputsdefined
keywordPublished by ilyash over 3 years ago
write(Str)
- write to stdoutdel(HashLike, Any)
- remove item from HashLike
, similar to del(Hash, Any)
trim(Str)
- trim whitespace at the beginning and end of the string-ppj
command line switch - print "pretty" JSON. Requires jq
program.assert(val, pattern, msg)
- val
must match the pattern
or AssertFail
will be thrown.Repeat
type - Signifies repetition of a pattern (or something else), to be used in patterns (and maybe somewhere else).group(Eachable1, Str)
- group by fielduniq(Eachable1, Str)
- uniq by fieldduplicates(Eachable1, field_or_callback)
- find duplicates=~
and !~
matching operators.Pred
machinery replaced with =~
and !~
match/non-match operators for simplification.guard
clauses are now using =~
and as a result are more concise.inspect()
now shows attributes (including documentation) of methods and types.uniq()
now works with Eachable1
(previously Arr
) and has optional callback.reduce(Eachable1, Fun)
now does not assume that the given Eachable1
supports Iter()
encode_json()
now supports hints
optional prameter (of type Hash
). pretty
hint with true
value will "prettify" the output.partition(Eachable1, pattern)
now has default pattern (Bool.constructors
)store()
now supports hints
optional prameter (of type Hash
). pretty
hint with true
value will "prettify" the output.require()
now treats ./something.ngs
as an absolute path (to fix later: treat as relative to the file)AnyOf
and AllOf
are no more experimental.Str(Set)
now works properly.exit_hook
robustness.map()
with invalid arity callback.=~
match against Arr
now matches element-wise. Previously only one-element-array was supported as the second argument and it had to match all elements of the first argument.Published by ilyash almost 4 years ago
Detailed list of changes is in CHANGELOG.md
Published by ilyash about 4 years ago
main()
can now be defined as part of Namespace
of the main file: ns { F main(...) ...}
only(val, predicate, mapper)
realpath(Str)
NGS_PATH
environment variable for require()
. NGS_DIR
is deprecated.$(log ...)
now logs i/o redirectionsValueWrapper
typeMY_NAMESPACE::main
works even if main
is not defined in the main file, allowing ngs -e 'require("my_module.ngs")
to run its own main()
filterk()
, rejectk()
, filterv()
, rejectv()
- the predicate is now optional and defaults to identity
.xxd
build time dependencysys/poll.h
dependency optionaln()
switch
and cond
are now consistent with if, accepting {...}
code blocks for the LHS (switch {a=1; a+a} {...}
, cond { {a=b+c; a>0 } ... }
).Published by ilyash about 4 years ago
Notable changes:
NamedInstances
type (aka enums)AllOf()
Detailed list of changes is in CHANGELOG.md
Published by ilyash-b almost 5 years ago
c_pthread_cond_*
methodsCond
type that exposes pthread_cond_*
functionalityBlockingList
linked list type with bocking shift()
and pop()
methodsExecutor
typeThreadedExecutor
type for simplified processing in threadspmap(Eachable1, Int, Fun)
- parallel map using limited numbers of threadspfilter(Eachable1, predicate)
- parallel filterpfilter(Eachable1, Int, predicate)
- parallel filter using limited numbers of threadsblock IDENTIFIER BODY
syntaxsection NAME BODY
syntaxTmpFile
- temporary file that is deleted automatically on exitProgram
(allows assert(Program("dd"))
)sortv()
OneOf
type (allows "abc" ~ OneOf(Int, Str)
)List
linked list typeJsonData
method which converts to JSON-compatible data structures; used by encode_json
now.has_no(container, element)
echo(ProcessesPipeline, Str)
ngs.vim
syntax filelines()
- returns all standard input as array of lineswords(Str)
Results
type, array-like with Result
itemsResultsException
type (with .results
being Results
type)List
typeinspect(Eachable1)
len(Box)
len(NumRange)
for Int
rangesRetryBodyMissing
exceptionNamespace
type. It is now returned by ns
block.Pred(NumRange)
.F default_argv_code() { fetch() }()
.~(x, t:Type)
has_index(Eachable1, Int)
len(Int)
Pred(OneOf)
TODO(Str)
ec2din.ngs
now takes expirimental -c COMMAND
Hash(Arr, Str)
is now Hash(Eachable1, Str)
(to support ArrLike
)Hash(Arr, Fun)
is now Hash(Eachable1, Fun)
(to support ArrLike
)install-mac.sh
(thanks for reporting, @zzamboni)executable
to inspect(Process)
and to exception reporting.basename()
is now implemented in stdlib.ngs
as opposed to previously using BASENAME(1)
.finished_ok()
now checks for known programs by their basename and not absolute paths (@zzamboni reported failing tests; this changes should fix it)echo(Int, Lines)
is now echo(Any, Lines)
wait(Process)
to behave correctly when exit_code
is not set but exit_signal
is set.$(blah >${true})
print_exception()
- add optional parameter echo
exception_specific_message()
- refactored for reusabilitypush(e:Enum, name:Str)
now returns e
stat()
methods now return timestamps too (access/modify/change)pmap()
now throws ResultsException
if any of the threads failStats()
now works with Eachable1
allowing counting characters in a string for examples$(... >${false})
syntaxc_strptime()
rand_uniq
implementationMatchSuccess
- include patternMatchFailure
- include data and patternget(Arr, Int, Any)
from C to stdlib and support negative indexes.first()
methods into oneHash
comparison for null
+
character is now valid "word" symbol - $(dig +short yahoo.com)
is now valid syntaxReturn
type and associated machineryfilter(Eachable1)
to_exit_code()
Published by ilyash-b over 5 years ago
This release adds new types, adds new methods, and contains various fixes. Listing most important changes:
$()
now returns ProcessesPipeline
(a new type). You should check all the places in your code that use CommandsPipeline
. Code that handles result of $(...)
should be changed to expect ProcessesPipeline
, not CommandsPipeline
.Lines
type. Array of strings to be processed as a unit for output purposes (echo
, warn
, error
).$(ok_sig: ...)
option. If external program terminates by specified signal, NGS will not throw exception.$(cd: ...)
option. Runs the external program in the specified directory.$(log: ...)
option. Logs the program to be executed first and then executes the program.Argv()
- support for arguments that need repeated argument nameBox()
now returns an EmptyBox
(thanks @organom !)Pred
improved so that .filter({"a": 1})
will not throw exception if there is no a
field.Detailed list of changes is in CHANGELOG.md
Published by ilyash-b about 6 years ago
exit()
methodmyip()
method (returns your IP as observable from the Internet)Detailed list of changes is in CHANGELOG.md
Published by ilyash over 6 years ago
Published by ilyash over 7 years ago
Fixes after pipes support
Published by ilyash over 7 years ago
write()
parameters swap: now - write(destination, data)Published by ilyash over 7 years ago