Giter VIP home page Giter VIP logo

krayola's People

Contributors

plastikfan avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

krayola's Issues

Add get-krayolatheme helper function

Add new function Get-KraylaTheme that gets the theme from the environment. This will allow different applicatins to get consistent display behaviour

branch: get-krayolatheme

Krayon: Add end method

When using the krayon from a command (as oppsed to a class method), the returned krayon instance (fluent style) can be a pain, because we always have to remember to assign the result to $null if we're not using it. The end function will do this for us, or at least relieve us from having to do that assignment.

Correct missing information in the documentation

The Theme parameter table does not match up with the parameter list in Write-RawPairsInColour. That's not the problem in itself, but the 2 lists are not the same, however, the documentation is misleading by simply deferring back to that table as if they were all the same. The following parameters need a comment (because they are not in the Theme table)

  • Pairs
  • Message

Define new command Show-Replay

New command that will simply re-render a .scribble file via Krayon.scribble. This will just reproduce the output that was captured inside the file. It's almost as if you were running the command again that produced this output, without actually doing so; hence Replay.

Make Get-KrayolaTheme safe

Make sure that all the themes that are stored inside the global KrayolThemes map are read only objects.

Make sure that we return a reference to the krayola theme, unless a new Switch (Clone) has been specified. A user might want to use a clone of the theme so they can make safe adjustments to a theme without affecting other clients.

Consolidate all files referencing classes into the same file

This is because of the problems with classes in PowerShell modules. The only reason why we don't have a problem in VSC with class references in files is because I already have Krayola installed on my machine and imported. In VSC powershell, the module has been imported so it can see the class definitions. However, these are the old class definitions which can't be modified after being defined in the same session. If somebody else checked out the repo without already having the module installed would see class reference erros in VSC.

So the best option would be to consolidate all the files into 1, bas work-around, but until class support in powershell has been improved, there is little else we can do.

Test are broken

How the fuck did this happen?

[+] C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Get-EnvironmentVariable.tests.ps1 557ms (73ms|381ms)
[-] Describe Get-KrayolaTheme failed
InvalidOperationException: Unable to remove the module 'Elizium.Krayola' because it is required by 'Elizium.Loopz'. Add the Force parameter to your command to remove the module.
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Get-KrayolaTheme.tests.ps1:5
Are you master of your domain? Yeah, Im still king of the county!
Are you master of your domain? Yeah, Im still lord of the manner!
This is affirmed text
This is key text
This is message text
This is meta text
This is value text
This is bold text
This is /italic/ text
This is s-t-r-i-k-e--t-h-r-u text
This is underlined text
"Album" => "Pungent Effulgent"
"Nine" => "Wreltch"
"Album" => "Pungent Effulgent"
"Artist" => "Ozric Tentacles"
"One" => "Disolution (The Clouds Disperse)"
"Two" => "0-1"
"Three" => "Phalarn Dawn"
"Four" => "04 - The Domes of G'Bal"
[-] Krayon.given: pair.and: pair created via New-Pair.should: write pair 21ms (20ms|1ms)
PSInvalidCastException: Cannot convert the "[Key: 'Five', Value: 'Shaping the Pelm', Affirm: 'True']" value of type "couplet" to type "couplet".
RuntimeException: Cannot convert the "[Key: 'Five', Value: 'Shaping the Pelm', Affirm: 'True']" value of type "couplet" to type "couplet".
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Krayon.tests.ps1:117
[-] Krayon.given: pair.and: pair created via kp alias.should: write pair 6ms (6ms|1ms)
PSInvalidCastException: Cannot convert the "[Key: 'Seven', Value: 'Kick Muck', Affirm: 'True']" value of type "couplet" to type "couplet".
RuntimeException: Cannot convert the "[Key: 'Seven', Value: 'Kick Muck', Affirm: 'True']" value of type "couplet" to type "couplet".
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Krayon.tests.ps1:129
["name" => "art vanderlay", "occupation" => "architect", "quip" => "i'm back baby, i'm back"]
Festivus for the rest of us // ["name" => "frank", "festivity" => "The airance of grievances"]
["one" => "(Dead But Dreaming)", "two" => "For her light", "three" => "At The Gates Of Silent Memory", "four" => "(Paradise Regained)", "five" => "Submission", "six" => "Sumerland (What Dreams May Come)"]
[-] Krayon.given: line.and: append to line.should: write line 10ms (9ms|1ms)
PSInvalidCastException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']; [Key: 'two', Value: 'Bango', Affirm: 'True']; [Key: 'three', Value: 'No Geography', Affirm: 'False']" value of type "line" to type "line".
RuntimeException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']; [Key: 'two', Value: 'Bango', Affirm: 'True']; [Key: 'three', Value: 'No Geography', Affirm: 'False']" value of type "line" to type "line".
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Krayon.tests.ps1:196
Fields Of The Nephilim, Love Under Will
I need to be alone today
Smother me or suffer me
Lay down I'll die today
*** Love under will //
!!! Love under will //
$$$ Love under will
Smother me or suffer me
Love Under Will //
When I'm gone wait here
Discover all of life's surprises
The Nephilim; Love Under Will // *The Winter Solstace
[🚀] ====== [ Children of the Damned ] ===
When I'm gone wait here
When I'm gone wait here
I'll send my child my last good smile
I'll love her 'til i
Then rest in peace can't you
If you pass through my soul today

[-] line.given: 2 equal lines.should: compare equal 11ms (11ms|1ms)
PSInvalidCastException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']; [Key: 'two', Value: 'Bango', Affirm: 'True']; [Key: 'three', Value: 'No Geography', Affirm: 'False']" value of type "line" to type "line".
RuntimeException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']; [Key: 'two', Value: 'Bango', Affirm: 'True']; [Key: 'three', Value: 'No Geography', Affirm: 'False']" value of type "line" to type "line".
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Krayon.tests.ps1:472
[-] line.given: 2 non equal lines.should: NOT compare equal 11ms (10ms|0ms)
PSInvalidCastException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']; [Key: 'two', Value: 'Bango', Affirm: 'True']; [Key: 'three', Value: 'No Geography', Affirm: 'False']" value of type "line" to type "line".
RuntimeException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']; [Key: 'two', Value: 'Bango', Affirm: 'True']; [Key: 'three', Value: 'No Geography', Affirm: 'False']" value of type "line" to type "line".
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Krayon.tests.ps1:493
[-] couplet.given: 2 equal couplets.should: compare equal 6ms (5ms|1ms)
PSInvalidCastException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']" value of type "couplet" to type "couplet".
RuntimeException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']" value of type "couplet" to type "couplet".
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Krayon.tests.ps1:521
[-] couplet.given: 2 non equal couplets.should: NOT compare equal 9ms (9ms|0ms)
PSInvalidCastException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']" value of type "couplet" to type "couplet".
RuntimeException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']" value of type "couplet" to type "couplet".
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Krayon.tests.ps1:533
[-] couplet.given: 2 non equal couplets.and: differs by case only.should: NOT compare equal 14ms (14ms|1ms)
PSInvalidCastException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']" value of type "couplet" to type "couplet".
RuntimeException: Cannot convert the "[Key: 'one', Value: 'Eve of Destruction', Affirm: 'False']" value of type "couplet" to type "couplet".
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Krayon.tests.ps1:543
[-] Split-KeyValuePairFormatter.Format is Key before Value.Given: minimal format.Should: return formatted string 21ms (20ms|0ms)
CommandNotFoundException: The term 'Split-KeyValuePairFormatter' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Split-KeyValuePairFormatter.tests.ps1:16
[-] Split-KeyValuePairFormatter.Format is Key before Value.Given: format with leading, mid and trailing tokens.Should: return formatted string 21ms (20ms|1ms)
CommandNotFoundException: The term 'Split-KeyValuePairFormatter' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Split-KeyValuePairFormatter.tests.ps1:34
[-] Split-KeyValuePairFormatter.Format is Value before Key.Given: minimal format.Should: return formatted string 26ms (25ms|1ms)
CommandNotFoundException: The term 'Split-KeyValuePairFormatter' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Split-KeyValuePairFormatter.tests.ps1:54
[-] Split-KeyValuePairFormatter.Format is Value before Key.Given: format with leading, mid and trailing tokens.Should: return formatted string 27ms (26ms|0ms)
CommandNotFoundException: The term 'Split-KeyValuePairFormatter' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at , C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Split-KeyValuePairFormatter.tests.ps1:72
[+] C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Write-ThemedPairsInColour.tests.ps1 803ms (286ms|447ms)
Tests completed in 4.96s
Tests Passed: 38, Failed: 21, Skipped: 1 NotRun: 0
BeforeAll \ AfterAll failed: 1

  • Get-KrayolaTheme
    Done /./Tests/Pester 00:00:05.4856893
    Done /./Tests 00:00:05.4880427
    Task /./Stats/RemoveStats skipped.
    Task /./Stats/WriteStats
    Done /./Stats/WriteStats 00:00:00.0643494
    Done /./Stats 00:00:00.0661086
    Done /. 00:00:06.0454102
    Build succeeded. 11 tasks, 0 errors, 0 warnings 00:00:06.1488487

Add note to readme.md about using single element array

As an aid to the user, need to add a reminder about the dangers of sintgle item Powershell array, that needs the use of the prefixing comma operator to prevent unwanted deconstruction of the array.

Also, put in a tip about the use of the += operator instead of using the Add method on a fixed item array.

Predefined themes contain strings defined with double quotes

When the module is imported, powershell is reporting the following errors:

At C:\Program Files\WindowsPowerShell\Modules\Elizium.Krayola\0.0.1\Public\themes.ps1:55 char:32
+     "OPEN"               = "â—„â—„â—„ <";
+                                ~~~~~~
Unexpected token 'â—„â—„' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\Elizium.Krayola\0.0.1\Public\themes.ps1:55 char:32
+     "OPEN"               = "â—„â—„â—„ <";
+                                ~
The hash literal was incomplete.
At C:\Program Files\WindowsPowerShell\Modules\Elizium.Krayola\0.0.1\Public\themes.ps1:55 char:31
+     "OPEN"               = "â—„â—„â—„ <";
+                               ~
The hash literal was incomplete.
At C:\Program Files\WindowsPowerShell\Modules\Elizium.Krayola\0.0.1\Public\themes.ps1:55 char:39
+     "OPEN"               = "â—„â—„â—„ <";
+                                       ~
The '<' operator is reserved for future use.
At C:\Program Files\WindowsPowerShell\Modules\Elizium.Krayola\0.0.1\Public\themes.ps1:60 char:33
+     "MESSAGE-SUFFIX"     = " // "
+                                 ~
The string is missing the terminator: ".
    + CategoryInfo          : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : UnexpectedToken

However does not affect the functionality. Also, this only appears to happen when the module is is installed for all users in 'Program Files\WindowsPowerShell\Modules'. This was not observed, when the module is installed for the local user under their own personal ~\Documents location. Also, this has not been observed on mac.

The errors could be caused by the fact that the string are be defined by double quotes rather than single quotes, because it looks like PowerShell is trying to evaluate the contents of these strings when it shuld not.

To fix, replace the double quotes with the single quotes. The characters causing problems appear to be '>', '<' and '/'.

branch: fix-theme-double-quotes

Rename writer class to krayon

[writer] as a class name is too generic and non specific. Krayon is very unique and therefore a better name in global scope

Pre-publish optimisations

On final review of the module prior to it being published show there were a fe minor issues that need to be address:

  • The name of the exported variable $DefinedThemes, is too generic, should be changed to KrayolaThemes.
  • Ensure that the emergency Themes has not been compromised
  • Change the name of the parameter $ColouredTextLine to $TextSnippets in function Write-InColour
  • Change function name Write-ColouredPairs to Write-ThemedColouredPairs
  • Change function name Write-PairsInColour to Write-RawPairsInColour

Krayon.Sribble doesnt handle empty string

This scenario results in an invalid operation being generated as a result of the internal parse:

[-] Show-AsTable.Krayon.Scribble.given: empty string.should: ignore without barfing 10ms (10ms|1ms)
 MethodException: Cannot find an overload for "Text" and the argument count: "0".
 at Scribble, C:\Program Files\PowerShell\Modules\Elizium.Krayola\1.0.2\Elizium.Krayola.psm1:1228
 at <ScriptBlock>, C:\Users\Plastikfan\dev\github\PoSh\Loopz\Elizium.Loopz\Tests\Public\ui\Show-AsTable.tests.ps1:60

This is as a result of generating a 'Text' api operation without an arg which means its trying to inovke the Text method on krayon without a text arg, which is not supported.

Rename source files

Some source files are not named in the standard way, ie exactly reflecting the name of the function it contains.

branch: rename-files

Minor non functional improvements

Set-Alias does not need to be called explicitly, we can just use the Alias decorator attribute on a function defintion

Write-ThemedPairsInColour contains non parameter variable names in capitalised from eg 'PairsToWriteInColour', should be 'pairsToWriteInColour'. Check this isnt happening elsewhere.

In the README, in the introduction, there is an incorrect reference to Write-Colour, which should be Write-InColour

Use Parameter validation where appropriate

branch: minor-non-fn

Host.ui.rawui.foregroundcolor/backgroundcolor are not set on mac

this causes errors when trying to write in colour.

The following code in Krayon constructor cause error, because for some reason it is set to -1:

    $this._defaultFgc = (Get-Host).ui.rawui.ForegroundColor;
    $this._defaultBgc = (Get-Host).ui.rawui.BackgroundColor;

This appears to be a problem in PowerShell.

On mac:

λ $host.ui.RawUI.ForegroundColor
-1


λ (get-host).ui.rawui | Format-List -Property *

ForegroundColor       : -1
BackgroundColor       : -1
CursorPosition        : 0,52
WindowPosition        : 0,0
CursorSize            : 100
BufferSize            : 214,53
WindowSize            : 214,53
MaxWindowSize         : 214,53
MaxPhysicalWindowSize : 214,53
KeyAvailable          : False
WindowTitle           :

On windows:

λ (get-host).ui.rawui | Format-List -Property *

ForegroundColor       : Gray
BackgroundColor       : Black
CursorPosition        : 0,59
WindowPosition        : 0,0
CursorSize            : 25
BufferSize            : 213,60
WindowSize            : 213,60
MaxWindowSize         : 213,60
MaxPhysicalWindowSize : 1904,70
KeyAvailable          : True
WindowTitle           : Elizium.Krayola

Invoke-MirrorDirectoryTree, CopyFiles depends on CreateDirs

CopyFiles switch should be able to work independently from CreateDirs. currently, CopyFiles has not effect unless CreateDirs is also set. There is a useful usecase that requires this decoupling. If you want to mirror and directory tree, but in the destination tree, you only want to copy over some files that match a particluar filter (includes/excludes), then this won't work unless CreateDirs. If you also set CreateDirs, then this could result in empty directories in the destination, as a result of there being files that fail to pass the filter, but the directroy would be created anyway.

The much better way around this is to remove the need to also set the CreateDirs flag.

branch: feature/copyfiles-without-createdirs

Write with 'Krayons'

Another way to write, would be to embed colour infomation inside text eg

"Something to say: {blue:-}, I've got chills, {red:-} and now I'm feeling hot".

Where the tokens inside {} are called Krayons and control the colour being rendered.
This functionality represents 'unstructured' writes.

All ErrorActions should be set to continue

If a critical function is using this module to produce output, it would be harmful for the process to be halted just becuase of a relatively un important display issue. The process should be allowed to run to completion, even if the display is not what is expected.

Perhap, we need to consult ErrorAction behaviour to make sure we take the correct action.

branch: fix-error-action

Build script has forked from other repos

  • KRAYOLA
  • renamed PsmPath to OutPsmPath
  • additional exports (for exporting classes and class factory functions)
  • new definitions: AdditionExportsPath, Get-AdditionalFnExports, Get-AdditionalAliasExports
  • modified definitions: Get-FunctionExportList, Get-PublicFunctionAliasesToExport
  • LOOPZ
  • custom module using (so that it can import from Krayola!)
  • new definitions:
  • modified definitions: Compile Task

Related to EliziumNet/Loopz#105

Tidy README

Lots of lint warnings in README. Also add in badges

writer: add format properties

Add properties to writer to denote the format to use to create api calls inside a structured string, which correspond to the expression that the writer is created with.

Remove all exception handling

Errors should not be absorbed and hidden as they are with the catch, even though the error is actually written out, but does not appear in the console.

Add platyPS documentation

Add a tip somewhere, tht custom themes maybe added to themes and it would be a god idea to add this to the powershell profile to make it persitent.

Module not found error on Tests

Why this error didnt make itself apparent before is a mystery. There is no way it should have got into ths state whilst tests have been running previously.

[+] C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Get-EnvironmentVariable.tests.ps1 535ms (75ms|339ms)
[-] Describe Get-KrayolaTheme failed
 FileNotFoundException: The specified module '.\Elizium.Krayola\Elizium.Krayola.psm1' was not loaded because no valid module file was found in any module directory.
 at <ScriptBlock>, C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Get-KrayolaTheme.tests.ps1:6
[-] Describe Split-KeyValuePairFormatter failed
 FileNotFoundException: The specified module '.\Elizium.Krayola\Elizium.Krayola.psm1' was not loaded because no valid module file was found in any module directory.
 at <ScriptBlock>, C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Split-KeyValuePairFormatter.tests.ps1:5
[-] Describe Write-ThemedPairsInColour failed
 FileNotFoundException: The specified module '.\Elizium.Krayola\Elizium.Krayola.psm1' was not loaded because no valid module file was found in any module directory.
 at <ScriptBlock>, C:\Users\Plastikfan\dev\github\PoSh\Krayola\Elizium.Krayola\Tests\Write-ThemedPairsInColour.tests.ps1:5
Tests completed in 1.3s
Tests Passed: 1, Failed: 20, Skipped: 0 NotRun: 0
BeforeAll \ AfterAll failed: 3
  - Get-KrayolaTheme
  - Split-KeyValuePairFormatter
  - Write-ThemedPairsInColour
Done /./Tests/Pester 00:00:01.8213733

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.