This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def custom_serializer(obj): | |
if hasattr(obj, '__dict__'): | |
attributes = obj.__dict__ | |
elif hasattr(obj, '__slots__'): | |
attributes = {slot: getattr(obj, slot) for slot in obj.__slots__} | |
else: | |
attributes = {attr: getattr(obj, attr) for attr in dir(obj) if not attr.startswith('__')} | |
# Convert Enum attributes to their values | |
return {key: value.name if isinstance(value, Enum) else value for key, value in attributes.items()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env groovy | |
@Grab('info.picocli:picocli-groovy:4.3.2') | |
import groovy.json.JsonSlurper | |
@Grab('org.yaml:snakeyaml:1.17') | |
import org.yaml.snakeyaml.Yaml | |
import picocli.CommandLine | |
import picocli.CommandLine.Help.Ansi | |
import java.util.concurrent.Callable |