Skip to content

Commit

Permalink
feat: add mafic -v for version checking (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ooliver1 authored Oct 28, 2022
1 parent 70707bc commit 3dbf5ab
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 3 deletions.
28 changes: 25 additions & 3 deletions mafic/__libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"VoiceServerUpdatePayload",
"dumps",
"loads",
"version_info",
)

libraries = ("nextcord", "disnake", "py-cord", "discord.py", "discord")
Expand Down Expand Up @@ -59,21 +60,42 @@


if library == "nextcord":
from nextcord import Client, Guild, StageChannel, VoiceChannel, VoiceProtocol
from nextcord import (
Client,
Guild,
StageChannel,
VoiceChannel,
VoiceProtocol,
version_info,
)
from nextcord.abc import Connectable, GuildChannel
from nextcord.backoff import ExponentialBackoff
from nextcord.types.voice import (
GuildVoiceState as GuildVoiceStatePayload,
VoiceServerUpdate as VoiceServerUpdatePayload,
)
elif library == "disnake":
from disnake import Client, Guild, StageChannel, VoiceChannel, VoiceProtocol
from disnake import (
Client,
Guild,
StageChannel,
VoiceChannel,
VoiceProtocol,
version_info,
)
from disnake.abc import Connectable, GuildChannel
from disnake.backoff import ExponentialBackoff
from disnake.types.gateway import VoiceServerUpdateEvent as VoiceServerUpdatePayload
from disnake.types.voice import GuildVoiceState as GuildVoiceStatePayload
else:
from discord import Client, Guild, StageChannel, VoiceChannel, VoiceProtocol
from discord import (
Client,
Guild,
StageChannel,
VoiceChannel,
VoiceProtocol,
version_info,
)
from discord.abc import Connectable, GuildChannel
from discord.backoff import ExponentialBackoff
from discord.types.voice import (
Expand Down
61 changes: 61 additions & 0 deletions mafic/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# SPDX-License-Identifier: MIT

from __future__ import annotations

import platform
import sys
from argparse import ArgumentParser, Namespace

import aiohttp

import mafic

from .__libraries import library, version_info

VERSION_OUTPUT = """
- Python v{py.major}.{py.minor}.{py.micro}-{py.releaselevel}
- mafic v{mafic}
- aiohttp v{aiohttp}
- {lib} v{pkg.major}.{pkg.minor}.{pkg.micro}-{pkg.releaselevel}
- system info: {uname.system} {uname.release} {uname.version}
""".strip()


def show_version():
version = mafic.__version__
uname = platform.uname()
print(
VERSION_OUTPUT.format(
py=sys.version_info,
mafic=version,
aiohttp=aiohttp.__version__,
uname=uname,
lib=library,
pkg=version_info,
)
)


def core(_: ArgumentParser, args: Namespace):
if args.version:
show_version()


def parse_args():
parser = ArgumentParser(prog="mafic", description="CLI tools for mafic")
parser.add_argument(
"-v",
"--version",
action="store_true",
help="shows mafic and other related versions",
)
return parser, parser.parse_args()


def main():
parser, args = parse_args()
core(parser, args)


if __name__ == "__main__":
main()

0 comments on commit 3dbf5ab

Please sign in to comment.