Skip to content

Detailed and colorful output - #15

Open
JoyHak wants to merge 1 commit into
Descolada:mainfrom
JoyHak:print-help
Open

Detailed and colorful output#15
JoyHak wants to merge 1 commit into
Descolada:mainfrom
JoyHak:print-help

Conversation

@JoyHak

@JoyHak JoyHak commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Colorful output

After messing around with colors for Launcher project I found a way to make fast color-formatting for console output. String.Prototype.Color() in Aris/Lib/Print.ahk now applies ANSI codes to the target message and Print() outputs formatted message to the CONOUT$ (*). I also added wrappers for warnings and errors in Aris/Lib/Print.ahk.
aris0

Help message

For some reason Aris misses very important --help, -h switch. Now it can display help message:

example description
aris -h detailed help message
aris install -h specific command help
aris --force -h specific switch help
aris -h commands specific help topic
aris -h commands,switches,... specific help topics
help-message help2

I don't understand how --alias works, so it's missing here, please add it. Also I don't understand other switches: --global, --local, --main. Please revise help message.

@Descolada

Copy link
Copy Markdown
Owner

Thanks for the PR! I finally had time to review it, and before merging could you fix some issues first?

  1. When I tried to install a package (eg 0w0Demonic/AquaHotkey) in a folder opened in the Aris GUI, I got this error:
Error: Too many parameters passed to function.

	---- Aris\Lib\print.ahk
	081: }
	083: {
▶	083: Return (Print(msg, "red", ,    "Iconx"), true)
	083: }
	084: {

Call stack:
Aris\Lib\print.ahk (83) : [PrintError] Return (Print(msg, "red", ,    "Iconx"), true)
Aris\Lib\print.ahk (87) : [PrintException] Return PrintError( "Uncaught error on line " ex.Line ": " ex.Message "
" . (ex.Extra ? "	Specifically: " ex.Extra "
" : "") )
Aris\aris.ahk (1003) : [InstallPackage] Print('Package "' IncludePackageName "@" Include.InstallVersion '" successfully installed.', "green")
Aris\Lib\ui-main.ahk (222) : [PackageAction] Result := InstallPackage(PackageInfo.PackageName)
> Gui
  1. print.ahk contains the following lines:
({}.DefineProp)(String.prototype, 'Color', {call: Colorize})
({}.DefineProp)(String.prototype, 'Strip', {call: DeColorize})

Those depend on being executed in the auto-execute section, which introduces a silent dependency of print.ahk being in a specific location in the code. It'd be better to either avoid modifying prototypes at all, or move them somewhere they are guaranteed to execute even when code is later moved around/changed.

  1. The git history would look prettier if you squashed the commits

@JoyHak

JoyHak commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

I missed this .__.
a

@JoyHak

JoyHak commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Everything should be fixed now
fixed

@Descolada

Copy link
Copy Markdown
Owner
OnExit((*) => DllCall("FreeConsole"))

FreeConsole returns a non-0 integer on success, and a non-0 callback result for OnExit prevents script exit, thus Aris wouldn't quit?

  1. PrintError returns true == 1, InstallPackage returns PrintError's result which indicates success and thus later the success path is taken.
  2. Print function error path uses MsgBox(msg.Strip(), "Aris", icon) which is unsuitable for a CLI application.
  3. PrintHelp checks the alias map but indexes the help map with the uncanonicalized alias. Thus commands like aris -h i, aris -h rm report "Item has no value" and exit with code 0 (indicating success).

@Qriist

Qriist commented Aug 27, 2026

Copy link
Copy Markdown
Contributor
OnExit((*) => DllCall("FreeConsole"))

FreeConsole returns a non-0 integer on success, and a non-0 callback result for OnExit prevents script exit, thus Aris wouldn't quit?

This is a common issue with cleaning up DLL calls at exit. It's solved by pointing OnExit at a tiny shim function/method which does the actual cleanup calls.

Here's a stripped example I use to implement my database library as a subclass without it hanging on exit:

initDB(pathToDB?,journal_mode := "wal",synchronous := 0){
	;truncated for clarity
		
	pathToDB ??= A_ScriptDir "\cache\" StrReplace(A_ScriptName,".ahk") ".db"
	this.acDB :=  SQriLiteDB()
	this.acDB.openDB(pathToDB)

	OnExit (*) => this._cleanup()
}
_cleanup(){
	this.CloseDB()
}
CloseDB(){
	this.acDB.exec("PRAGMA optimize;")
	return this.acDb.CloseDB()
}

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants