added a license and a 'version' flag in anticipation of release
This commit is contained in:
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2025 sotrali
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
+9
-1
@@ -1,6 +1,8 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
import math
|
import math
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
VERSION = 1.0
|
||||||
TYPES = ['hex', 'rgb', 'cmy', 'cmyk', 'hsl', 'hsv']
|
TYPES = ['hex', 'rgb', 'cmy', 'cmyk', 'hsl', 'hsv']
|
||||||
# look into LAB
|
# look into LAB
|
||||||
|
|
||||||
@@ -33,17 +35,23 @@ def main():
|
|||||||
parser.add_argument('--output', '-o', help='the name of a file to store output in (will create file if doesn\'t exist, will OVERWRITE existing file\'s contents)')
|
parser.add_argument('--output', '-o', help='the name of a file to store output in (will create file if doesn\'t exist, will OVERWRITE existing file\'s contents)')
|
||||||
parser.add_argument('--append', '-a', action='store_true', help='append rather than overwrite when outputting to file rather than stdout')
|
parser.add_argument('--append', '-a', action='store_true', help='append rather than overwrite when outputting to file rather than stdout')
|
||||||
parser.add_argument('--verbose', '-v', action='store_true', help='print when performing conversions')
|
parser.add_argument('--verbose', '-v', action='store_true', help='print when performing conversions')
|
||||||
|
parser.add_argument('--version', action='store_true', help='print current version')
|
||||||
|
|
||||||
parser.add_argument('color', nargs='*', help='a color in Hex, RGB, CMY, CMYK, HSL or HSV format')
|
parser.add_argument('color', nargs='*', help='a color in Hex, RGB, CMY, CMYK, HSL or HSV format')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
''' PROCESS ARGS '''
|
''' PROCESS ARGS '''
|
||||||
|
# simple version check
|
||||||
|
if args.version :
|
||||||
|
print('color-converter: CLI color code translator!')
|
||||||
|
print(' -- v.1.0 --- ')
|
||||||
|
|
||||||
# determine which conversions to perform
|
# determine which conversions to perform
|
||||||
outputFormats = []
|
outputFormats = []
|
||||||
flagsActive = 0
|
flagsActive = 0
|
||||||
for flag in vars(args).keys() :
|
for flag in vars(args).keys() :
|
||||||
# if the flag for an output type is present, keep trac
|
# if an output format flag is present, keep track
|
||||||
if (vars(args).get(flag, False)) and (flag in TYPES) :
|
if (vars(args).get(flag, False)) and (flag in TYPES) :
|
||||||
flagsActive += 1
|
flagsActive += 1
|
||||||
outputFormats.append(flag)
|
outputFormats.append(flag)
|
||||||
|
|||||||
Reference in New Issue
Block a user