Coverage for licenzy\cli.py: 0%

53 statements  

« prev     ^ index     » next       coverage.py v7.10.4, created at 2025-08-17 11:06 -0400

1""" 

2🖥️ Licenzy CLI - Command-line interface for license management 

3 

4Provides a clean, user-friendly CLI for managing licenses. 

5Built with Click for a great developer experience. 

6""" 

7 

8import click 

9from .management import activate_license, deactivate_license, show_license_status 

10from .core import check_license 

11 

12 

13@click.group() 

14@click.version_option(version="1.0.0") 

15def main(): 

16 """ 

17 🔑 Licenzy - Simple license management for AI tools 

18  

19 Licenzy provides easy license validation for your Python projects. 

20 Perfect for indie developers and small teams building AI tools. 

21 """ 

22 pass 

23 

24 

25@main.command() 

26@click.argument('license_key') 

27def activate(license_key: str): 

28 """ 

29 🔓 Activate a license key 

30  

31 LICENSE_KEY: Your license key string 

32  

33 Example: 

34 licenzy activate user123:pro:1735689600:abc123def456 

35 """ 

36 success = activate_license(license_key) 

37 if not success: 

38 raise click.ClickException("License activation failed") 

39 

40 

41@main.command() 

42def deactivate(): 

43 """ 

44 🔒 Deactivate the current license 

45  

46 Removes the stored license key from your system. 

47 """ 

48 deactivate_license() 

49 

50 

51@main.command() 

52def status(): 

53 """ 

54 📊 Show current license status 

55  

56 Displays detailed information about your license state. 

57 """ 

58 show_license_status() 

59 

60 

61@main.command() 

62def check(): 

63 """ 

64 ✅ Quick license validation check 

65  

66 Returns exit code 0 if valid, 1 if invalid. 

67 Perfect for scripts and automation. 

68 """ 

69 if check_license(): 

70 click.echo("✅ License is valid") 

71 else: 

72 click.echo("❌ License is invalid") 

73 raise click.ClickException("Invalid license") 

74 

75 

76@main.command() 

77def info(): 

78 """ 

79 ℹ️ Show Licenzy information and usage examples 

80 """ 

81 click.echo("🔑 Licenzy - Simple license management for AI tools") 

82 click.echo() 

83 click.echo("📋 Quick Start:") 

84 click.echo(" licenzy activate your-license-key # Activate license") 

85 click.echo(" licenzy status # Check status") 

86 click.echo(" licenzy check # Quick validation") 

87 click.echo() 

88 click.echo("🐍 Python Integration:") 

89 click.echo(" from licenzy import licensed, check_license") 

90 click.echo() 

91 click.echo(" @licensed") 

92 click.echo(" def premium_feature():") 

93 click.echo(" return 'This requires a license!'") 

94 click.echo() 

95 click.echo(" if check_license():") 

96 click.echo(" print('Access granted!')") 

97 click.echo() 

98 click.echo("🌐 Environment Variables:") 

99 click.echo(" LICENZY_LICENSE_KEY=your-key # Set license via env") 

100 click.echo(" LICENZY_DEV_MODE=true # Bypass for development") 

101 click.echo() 

102 click.echo("📁 License Storage Locations:") 

103 click.echo(" ~/.licenzy/license.key # User-specific") 

104 click.echo(" .licenzy_license # Project-specific") 

105 

106 

107if __name__ == "__main__": 

108 main()