13 changed files with 390 additions and 8 deletions
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?> |
||||
<configuration> |
||||
<startup> |
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" /> |
||||
</startup> |
||||
</configuration> |
Binary file not shown.
@ -0,0 +1,41 @@
|
||||
namespace SmoulderingBeachBallCLI.AssemblyInfo |
||||
|
||||
open System.Reflection |
||||
open System.Runtime.CompilerServices |
||||
open System.Runtime.InteropServices |
||||
|
||||
// General Information about an assembly is controlled through the following |
||||
// set of attributes. Change these attribute values to modify the information |
||||
// associated with an assembly. |
||||
[<assembly: AssemblyTitle("Smouldering Beach Ball CLI")>] |
||||
[<assembly: AssemblyDescription("")>] |
||||
[<assembly: AssemblyConfiguration("")>] |
||||
[<assembly: AssemblyCompany("")>] |
||||
[<assembly: AssemblyProduct("Smouldering Beach Ball CLI")>] |
||||
[<assembly: AssemblyCopyright("Copyright © 2018")>] |
||||
[<assembly: AssemblyTrademark("")>] |
||||
[<assembly: AssemblyCulture("")>] |
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible |
||||
// to COM components. If you need to access a type in this assembly from |
||||
// COM, set the ComVisible attribute to true on that type. |
||||
[<assembly: ComVisible(false)>] |
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM |
||||
[<assembly: Guid("5c00d583-ef09-4fe6-a3fe-eb01454c0607")>] |
||||
|
||||
// Version information for an assembly consists of the following four values: |
||||
// |
||||
// Major Version |
||||
// Minor Version |
||||
// Build Number |
||||
// Revision |
||||
// |
||||
// You can specify all the values or you can default the Build and Revision Numbers |
||||
// by using the '*' as shown below: |
||||
// [<assembly: AssemblyVersion("1.0.*")>] |
||||
[<assembly: AssemblyVersion("0.2.0.0")>] |
||||
[<assembly: AssemblyFileVersion("0.2.0.0")>] |
||||
|
||||
do |
||||
() |
@ -0,0 +1,114 @@
|
||||
namespace Commands |
||||
|
||||
module ConsoleCommands = |
||||
|
||||
open System |
||||
open Console.Waterworks |
||||
open Console.Waterworks.Attributes |
||||
open SmoulderingBeachBall.Services |
||||
open Validation |
||||
open System.IO |
||||
|
||||
let showEndOfCommandMessage = "[INFO.] Execution completed." |
||||
|
||||
[<ListCommand>] |
||||
[<Parameters "none">] |
||||
[<Description |
||||
"Display a text message indicating this program is running properly.">] |
||||
[<Usage "test">] |
||||
let test () = "[SUCCESS] Smouldering Beach Ball CLI seems to be working." |
||||
|
||||
[<ListCommand>] |
||||
[<Parameters "none">] |
||||
[<Description "Displays a list of available commands provided by this program.">] |
||||
[<Usage "help">] |
||||
let help () = CW_Liaison().RequestHelpDocumentation("Commands") |
||||
|
||||
[<ListCommand>] |
||||
[<Parameters "none">] |
||||
[<Description "Saves this program's cheat sheet to the desktop.">] |
||||
[<Usage "cheat">] |
||||
let cheat () = |
||||
try |
||||
printfn "[INFO] Attempting to save cheat sheet to the desktop..." |
||||
let cheatSheetPath = __SOURCE_DIRECTORY__ + "/cheat-sheet.pdf" |
||||
let savePath = getDesktopPath + "/smouldering-beach-ball-cheat-sheet.pdf" |
||||
File.Copy (cheatSheetPath, savePath, true) |
||||
showEndOfCommandMessage |
||||
with |
||||
| :? FileNotFoundException as ex -> ex.Message |
||||
| _ as ex -> ex.Message |
||||
|
||||
[<ListCommand>] |
||||
[<Parameters "none">] |
||||
[<Description "Exits out of the program.">] |
||||
[<Usage "exit">] |
||||
let exit () = Environment.Exit (Environment.ExitCode) |
||||
|
||||
[<ListCommand>] |
||||
[<Parameters "(image-width: int) (image-height: int)" >] |
||||
[<Description |
||||
("Saves an image to the desktop, using the default setting.\n" + |
||||
"The user must specify the width and the height of the image.")>] |
||||
[<Usage "draw-default 500 500">] |
||||
let ``draw-default`` imgWidth imgHeight = |
||||
try |
||||
buildDefaultSpec imgWidth imgHeight |
||||
|> makeImage |
||||
|> Async.RunSynchronously |
||||
showEndOfCommandMessage |
||||
with |
||||
| :? ArgumentException as ex -> ex.Message |
||||
| _ as ex -> ex.Message |
||||
|
||||
[<ListCommand>] |
||||
[<Parameters |
||||
("(image-width: int) (image-height: int) (main-colour: string) " + |
||||
"(overlay-colour: string) (overlay-type:string) (file-path: string)")>] |
||||
[<Description |
||||
("\nCreates an image using the values specified by the user.\n" + |
||||
"To see a list of available colours use the 'list-colours' command.\n" + |
||||
"For the overlay-type you can enter either 'none', 'border' or 'full.'\n" + |
||||
"For the file path, you can enter 'desktop' to save to the desktop." + |
||||
"Otherwise, you must specify the whole path.")>] |
||||
[<Usage |
||||
("\ndraw-image 770 400 white black full desktop\n" + |
||||
"draw-image 600 400 purple gray border C:/work/project-folder/images\n" + |
||||
"draw-image 800 440 black - none D:/your-project/assets")>] |
||||
let ``draw-image`` imgWidth imgHeight mainColour oColour oType path = |
||||
try |
||||
buildSpec imgWidth imgHeight mainColour oColour oType path |
||||
|> makeImage |
||||
|> Async.RunSynchronously |
||||
showEndOfCommandMessage |
||||
with |
||||
| :? ArgumentException as ex -> ex.Message |
||||
| _ as ex -> ex.Message |
||||
|
||||
[<ListCommand>] |
||||
[<Parameters "None">] |
||||
[<Description |
||||
"Lists out the colours this program uses to draw its images.">] |
||||
[<Usage "list-colours">] |
||||
let ``list-colours`` () = |
||||
printfn "[INFO.] Listing available colours..." |
||||
for item in colourList do |
||||
printfn "%s" item.Key |
||||
showEndOfCommandMessage |
||||
|
||||
(* ALIASES |
||||
======================================================================= |
||||
These command-methods will not show up in the help section. |
||||
Before adding extra aliases, make sure the main version is as clear and |
||||
helpful to someone new to the program as possible. Aliases should be |
||||
treated as commands for experienced users and documented on the wiki, |
||||
hosted alongside the repository on GitHub. |
||||
URL: https://github.com/CraigOates/Smouldering-Beach-Ball/wiki *) |
||||
|
||||
let dd imgWidth imgHeight = |
||||
``draw-default`` imgWidth imgHeight |
||||
|
||||
let di imgWidth imgHeight mainColour oColour oType path = |
||||
``draw-image`` imgWidth imgHeight mainColour oColour oType path |
||||
|
||||
let lc () = ``list-colours`` () |
@ -0,0 +1,7 @@
|
||||
open Console.Waterworks |
||||
|
||||
[<EntryPoint>] |
||||
let main argv = |
||||
let liaison = new CW_Liaison () |
||||
liaison.Run ("Commands", true) |
||||
0 // return an integer exit code |
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
||||
<PropertyGroup> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<SchemaVersion>2.0</SchemaVersion> |
||||
<ProjectGuid>5c00d583-ef09-4fe6-a3fe-eb01454c0607</ProjectGuid> |
||||
<OutputType>Exe</OutputType> |
||||
<RootNamespace>SmoulderingBeachBallCLI</RootNamespace> |
||||
<AssemblyName>SmoulderingBeachBallCLI</AssemblyName> |
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> |
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
||||
<UseStandardResourceNames>true</UseStandardResourceNames> |
||||
<Name>SmoulderingBeachBallCLI</Name> |
||||
<Win32Resource>..\SmoulderingBeachBallCLI\AppIcon.res</Win32Resource> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>full</DebugType> |
||||
<Optimize>false</Optimize> |
||||
<Tailcalls>false</Tailcalls> |
||||
<OutputPath>bin\$(Configuration)\</OutputPath> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<WarningLevel>3</WarningLevel> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<DocumentationFile> |
||||
</DocumentationFile> |
||||
<Prefer32Bit>false</Prefer32Bit> |
||||
<OtherFlags> |
||||
</OtherFlags> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
||||
<DebugType>pdbonly</DebugType> |
||||
<Optimize>true</Optimize> |
||||
<Tailcalls>true</Tailcalls> |
||||
<OutputPath>bin\$(Configuration)\</OutputPath> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<WarningLevel>3</WarningLevel> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<DocumentationFile> |
||||
</DocumentationFile> |
||||
<Prefer32Bit>true</Prefer32Bit> |
||||
</PropertyGroup> |
||||
<PropertyGroup> |
||||
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(FSharpTargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets') "> |
||||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath> |
||||
</PropertyGroup> |
||||
<Import Project="$(FSharpTargetsPath)" /> |
||||
<ItemGroup> |
||||
<Compile Include="AssemblyInfo.fs" /> |
||||
<Compile Include="Validation.fs" /> |
||||
<Compile Include="ConsoleCommands.fs" /> |
||||
<Compile Include="Program.fs" /> |
||||
<None Include="App.config" /> |
||||
<Content Include="packages.config" /> |
||||
<Content Include="icon.ico" /> |
||||
<None Include="AppIcon.res" /> |
||||
<None Include="cheat-sheet.pdf" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Reference Include="Console.Waterworks"> |
||||
<HintPath>..\packages\Console.Waterworks.0.1.0.0-alpha1\lib\Console.Waterworks.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="FSharp.Core"> |
||||
<HintPath>..\packages\FSharp.Core.4.5.2\lib\net45\FSharp.Core.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="mscorlib" /> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Drawing.Common"> |
||||
<HintPath>..\packages\System.Drawing.Common.4.5.0\lib\net461\System.Drawing.Common.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="System.Numerics" /> |
||||
<Reference Include="System.ValueTuple"> |
||||
<Private>True</Private> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\SmoulderingBeachBall\SmoulderingBeachBall.fsproj"> |
||||
<Name>SmoulderingBeachBall</Name> |
||||
<Project>{dfc3cbca-3da7-4cf4-a8bc-bccb740fa6cd}</Project> |
||||
<Private>True</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
||||
Other similar extension points exist, see Microsoft.Common.targets. |
||||
<Target Name="BeforeBuild"> |
||||
</Target> |
||||
<Target Name="AfterBuild"> |
||||
</Target> |
||||
--> |
||||
</Project> |
@ -0,0 +1,85 @@
|
||||
module internal Validation |
||||
|
||||
open System.Drawing |
||||
open SmoulderingBeachBall.Domain.DomainTypes |
||||
open System |
||||
|
||||
let colourList = |
||||
[ "blue", Brushes.AliceBlue; |
||||
"brown", Brushes.Brown; |
||||
"black", Brushes.Black; |
||||
"gray", Brushes.Gray; |
||||
"green", Brushes.Green; |
||||
"purple", Brushes.Purple; |
||||
"red", Brushes.Red; |
||||
"white", Brushes.White; |
||||
"yellow", Brushes.Yellow;] |
||||
|> Map.ofList |
||||
|
||||
let isColourValid (colour: string) = |
||||
colourList |
||||
|> Map.containsKey (colour.ToLower()) |
||||
|
||||
let parseColour colour = |
||||
match (isColourValid colour) with |
||||
| true -> |
||||
colourList |
||||
|> Map.find (colour.ToLower()) |
||||
| false -> |
||||
invalidArg "Colour" |
||||
(String.Concat("[ERROR] The colour specifed is invalid.\n", |
||||
"Please use the 'list-colours' command to see what you can use.")) |
||||
|
||||
let getDesktopPath = |
||||
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) |
||||
|
||||
let parsePath (path: string) = |
||||
match path with |
||||
| path when ((path.ToLower()).Equals "desktop") -> getDesktopPath |
||||
| path when ((path.ToLower()).Equals "d") -> getDesktopPath |
||||
| _ -> path |
||||
|
||||
let buildDefaultSpec iWidth iHeight = |
||||
let oSpec = |
||||
{ colour = Brushes.Black |
||||
overlayType = Full } |
||||
let spec = |
||||
{ width = iWidth |
||||
height = iHeight |
||||
colour = Brushes.AntiqueWhite |
||||
filePath = getDesktopPath |
||||
overlay = Some oSpec |
||||
} |
||||
spec |
||||
|
||||
let parseOverlay (oType: string) = |
||||
match oType.ToLower() with |
||||
| "border" -> Border |
||||
| "b" -> Border |
||||
| "full" -> Full |
||||
| "f" -> Full |
||||
| _ -> invalidArg "Overlay Type" "The overlay type must be either 'border' or 'full'." |
||||
|
||||
let buildOverlaySpec oColour (oType: string) = |
||||
let oSpec = |
||||
{ colour = parseColour oColour; |
||||
overlayType = parseOverlay oType } |
||||
oSpec |
||||
|
||||
let buildMainSpec iWidth iHeight mainColour path oSpec = |
||||
let spec = |
||||
{ width = iWidth; |
||||
height = iHeight; |
||||
colour = parseColour mainColour |
||||
filePath = parsePath path |
||||
overlay = oSpec } |
||||
spec |
||||
|
||||
let buildSpec iWidth iHeight mainColour oColour (oType: string) path = |
||||
let spec = |
||||
match oType.ToLower() with |
||||
| "none" | "n" -> buildMainSpec iWidth iHeight mainColour path option.None |
||||
| _ -> |
||||
let oSpec = buildOverlaySpec oColour oType |
||||
buildMainSpec iWidth iHeight mainColour path (Some oSpec) |
||||
spec |
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<packages> |
||||
<package id="Console.Waterworks" version="0.1.0.0-alpha1" targetFramework="net471" /> |
||||
<package id="FSharp.Core" version="4.5.2" targetFramework="net471" /> |
||||
<package id="System.Drawing.Common" version="4.5.0" targetFramework="net471" /> |
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net471" /> |
||||
</packages> |
Loading…
Reference in new issue