feat: reorder subscriptions
This commit is contained in:
@ -206,7 +206,8 @@ func (m *Manager) DeactivateSubscription(name string) {
|
||||
}
|
||||
}
|
||||
|
||||
// ListSubscriptions prints all subscriptions.
|
||||
// ListSubscriptions prints all subscriptions in display order (see
|
||||
// model.SubscriptionsData.OrderedNames / `subscription move`).
|
||||
func (m *Manager) ListSubscriptions() {
|
||||
if len(m.Data.Subscriptions) == 0 {
|
||||
fmt.Println("No subscriptions found")
|
||||
@ -214,7 +215,8 @@ func (m *Manager) ListSubscriptions() {
|
||||
}
|
||||
|
||||
fmt.Println("📋 Subscriptions:")
|
||||
for name, sub := range m.Data.Subscriptions {
|
||||
for _, name := range m.Data.OrderedNames() {
|
||||
sub := m.Data.Subscriptions[name]
|
||||
activeMarker := "⚪"
|
||||
if sub.Status == model.StatusActive {
|
||||
activeMarker = "✅"
|
||||
@ -229,6 +231,28 @@ func (m *Manager) ListSubscriptions() {
|
||||
}
|
||||
}
|
||||
|
||||
// MoveSubscription repositions name immediately before or after target in
|
||||
// the display/merge order.
|
||||
func (m *Manager) MoveSubscription(name, target string, before bool) {
|
||||
if m.Data.MoveSubscription(name, target, before) {
|
||||
if m.Storage.SaveSubscriptions(m.Data) {
|
||||
position := "after"
|
||||
if before {
|
||||
position = "before"
|
||||
}
|
||||
fmt.Printf("✅ Moved subscription '%s' %s '%s'\n", name, position, target)
|
||||
} else {
|
||||
fmt.Println("❌ Failed to move subscription")
|
||||
}
|
||||
} else if name == target {
|
||||
fmt.Println("❌ Cannot move a subscription relative to itself")
|
||||
} else if _, ok := m.Data.Subscriptions[name]; !ok {
|
||||
fmt.Printf("❌ Subscription '%s' not found\n", name)
|
||||
} else {
|
||||
fmt.Printf("❌ Subscription '%s' not found\n", target)
|
||||
}
|
||||
}
|
||||
|
||||
// GetSubscriptionURL prints the URL for a subscription.
|
||||
func (m *Manager) GetSubscriptionURL(name string) {
|
||||
sub, ok := m.Data.Subscriptions[name]
|
||||
|
||||
Reference in New Issue
Block a user