"""
# Cirrus.App Automation Tool

A Python automation class for managing application info, executing shell commands (DOS/PowerShell), and handling file compression.

## Functions & Methods

### Initialization & Info
*   `__init__(name, version, copyright)`: Initializes the application, sets the start time, prints app info, and checks for help arguments.
*   `WriteAppInfo()`: Displays the application name, version, and copyright.
*   `DisplayHelp()`: Checks `sys.argv` for `?`, `-h`, or `help` to trigger `HelpScreen()`.
*   `HelpScreen()`: Prints usage instructions.
*   `QuitApp(runningTime)`: Prints the elapsed execution time.

### Shell & Command Execution
*   `dos(cmd)`: Runs a command in the Windows DOS (`cmd.exe`) shell using `subprocess` [7].
*   `ps1(cmd)`: Runs a command in PowerShell (`powershell.exe`) using `subprocess`.
*   `sh(cmd)`: Executes a command directly via the system shell.

## Usage
```python
app = App("MyApp", "1.0", "(C) Copyright 2024")
app.dos("dir")
app.QuitApp()
"""

from datetime import datetime
import getopt, os, subprocess, sys, zipfile


class App:
	_startDate = ""	
	_exitScript = False


	#== Constructor ===============================================================================


	def __init__(this, name="Cirrus.App", version="1.0.0", copyright = "2024"):
		this._startDate = datetime.now()

		this.name = name
		this.version = version
		this.copyright = copyright

		this.WriteAppInfo()
		this.DisplayHelp()		


	#== App Info Methods ==========================================================================


	def DisplayHelp(this):
		if (("?" in sys.argv) or ("-h" in sys.argv) or ("help" in sys.argv)):
			this.HelpScreen()
			this._exitScript = True
	
	def HelpScreen(this):
		print("Help Screen")

	def WriteAppInfo(this):
		print(f"\n{this.name} {this.version}")
		print(f"Copyright (C) {this.copyright}")
		print("---\n")

	def QuitApp(this, runningTime = True, color = "\033[0;37m"):
		defaultColor = "\033[0;37m"

		if (runningTime):
			print(f"\n{color}Running time: {datetime.now() - this._startDate}{defaultColor}\n")


	#== Shell Methods =============================================================================


	#
	# SUMMARY: run a command in the DOS shell.
	#
	# PARAMETERS: cmd - the command to run.
	#
	def dos(this, cmd):
		subprocess.call('cmd.exe /c ' + cmd, shell=True)


	#
	# SUMMARY: run a command in 
	#
	# PARAMETERS: cmd - the command to run.
	#
	def ps1(this, cmd):
		subprocess.call('powershell.exe ' + cmd, shell=True)


	#
	# SUMMARY: run a command in the DOS shell.
	#
	# PARAMETERS: cmd - the command to run.
	#
	def sh(this, cmd):
		subprocess.call(cmd, shell=True)